Skip to content

Commit 79443cd

Browse files
bulk88khwilliamson
authored andcommitted
regcomp_invlist.c -> S_invlist_trim -> SvPV_renew bug demo
1 parent fd8f7c8 commit 79443cd

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
@@ -11878,7 +11878,7 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int
1187811878

1187911879
/* if we allocated too much space, give some back */
1188011880
if (SvCUR(sv) + 5 < SvLEN(sv)) {
11881-
SvLEN_set(sv, SvCUR(sv) + 1);
11881+
/* XXX SvLEN_set(sv, SvCUR(sv) + 1); */
1188211882
SvPV_shrink_to_cur(sv);
1188311883
}
1188411884

0 commit comments

Comments
 (0)