Skip to content

Commit 44c5238

Browse files
committed
regcomp_invlist.c -> S_invlist_trim -> SvPV_renew bug demo
1 parent 7946d6a commit 44c5238

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

regcomp_invlist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ S_invlist_trim(SV* invlist)
247247

248248
/* But don't free up the space needed for the 0 UV that is always at the
249249
* beginning of the list, nor the trailing NUL */
250-
const UV min_size = TO_INTERNAL_SIZE(1) + 1;
250+
const UV min_size = TO_INTERNAL_SIZE(1) + 1; /* XXX 64bit UVs malloc()s on 32b CPU ? */
251251

252252
PERL_ARGS_ASSERT_INVLIST_TRIM;
253253

254254
assert(is_invlist(invlist));
255255

256-
SvPV_renew(invlist, MAX(min_size, SvCUR(invlist) + 1));
256+
SvPV_renew(invlist, MAX(min_size, SvCUR(invlist) + 1)); /* XXX bug ??? */
257257
}
258258

259259
PERL_STATIC_INLINE void

sv.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,9 @@ why not just use C<SvGROW> if you're not sure about the provenance?
15701570
15711571
=cut
15721572
*/
1573-
#define SvPV_renew(sv,n) \
1574-
STMT_START { SvLEN_set(sv, n); \
1573+
#define SvPV_renew(sv,n) STMT_START { \
1574+
assert(SvLEN(sv) > n && n > 0);\
1575+
SvLEN_set(sv, n); \
15751576
SvPV_set((sv), (MEM_WRAP_CHECK_(n,char) \
15761577
(char*)saferealloc((Malloc_t)SvPVX(sv), \
15771578
(MEM_SIZE)((n))))); \

toke.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11873,7 +11873,7 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int
1187311873

1187411874
/* if we allocated too much space, give some back */
1187511875
if (SvCUR(sv) + 5 < SvLEN(sv)) {
11876-
SvLEN_set(sv, SvCUR(sv) + 1);
11876+
/* XXX SvLEN_set(sv, SvCUR(sv) + 1); */
1187711877
SvPV_shrink_to_cur(sv);
1187811878
}
1187911879

0 commit comments

Comments
 (0)