Skip to content

Commit a2756b5

Browse files
committed
pack: allocate msgs AV before pushing to it
This is an oversight from commit b0c3c5f. We need to make sure msgs is not NULL before we can start pushing values. Fixes a Coverity report: 324 if (msgs) { >>> CID 584148: Possible Control flow issues (DEADCODE) >>> Execution cannot reach this statement: "while (Perl_av_count(my_per...". 325 while (av_count(msgs) > 0) { (Coverity thinks the code is unreachable because it is guarded by an 'if (msgs)' statement, and 'msgs' is initialized to NULL and never modified afterwards. In reality, it would probably crash in av_push() if any warnings were to be generated.)
1 parent 93fbcb7 commit a2756b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pp_pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ S_utf8_to_bytes(pTHX_ const char **s, const char *end, const char *buf, SSize_t
308308
* */
309309
if (this_msgs) {
310310
while (av_count(this_msgs) > 0) {
311-
av_push(msgs, av_shift(this_msgs));
311+
Perl_av_create_and_push(aTHX_ &msgs, av_shift(this_msgs));
312312
}
313313

314314
Safefree(this_msgs);

0 commit comments

Comments
 (0)