Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit75240f6

Browse files
committed
jsonapi: fix memory leakage during OOM error recovery.
Coverity pointed out that inc_lex_level() would leak memory(not to mention corrupt the pstack data structure) if somebut not all of its three REALLOC's failed. To fix, storesuccessfully-updated pointers back into the pstack structimmediately.Oversight in0785d1b, so no need for back-patch.
1 parenta7e5237 commit75240f6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

‎src/common/jsonapi.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,19 +544,28 @@ inc_lex_level(JsonLexContext *lex)
544544

545545
new_prediction=REALLOC(lex->pstack->prediction,
546546
new_stack_size*JS_MAX_PROD_LEN);
547+
#ifdefJSONAPI_USE_PQEXPBUFFER
548+
if (!new_prediction)
549+
return false;
550+
#endif
551+
lex->pstack->prediction=new_prediction;
552+
547553
new_fnames=REALLOC(lex->pstack->fnames,
548554
new_stack_size*sizeof(char*));
549-
new_fnull=REALLOC(lex->pstack->fnull,new_stack_size*sizeof(bool));
555+
#ifdefJSONAPI_USE_PQEXPBUFFER
556+
if (!new_fnames)
557+
return false;
558+
#endif
559+
lex->pstack->fnames=new_fnames;
550560

561+
new_fnull=REALLOC(lex->pstack->fnull,new_stack_size*sizeof(bool));
551562
#ifdefJSONAPI_USE_PQEXPBUFFER
552-
if (!new_prediction|| !new_fnames|| !new_fnull)
563+
if (!new_fnull)
553564
return false;
554565
#endif
566+
lex->pstack->fnull=new_fnull;
555567

556568
lex->pstack->stack_size=new_stack_size;
557-
lex->pstack->prediction=new_prediction;
558-
lex->pstack->fnames=new_fnames;
559-
lex->pstack->fnull=new_fnull;
560569
}
561570

562571
lex->lex_level+=1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp