Skip to content

Commit 0e2ceb2

Browse files
authored
Merge pull request #4050 from Adenilson/fix_legacy_nullptr01
[fix] Add check on failed allocation in legacy/zstd_v06
2 parents 78955f5 + 1872688 commit 0e2ceb2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/legacy/zstd_v06.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3919,6 +3919,10 @@ ZBUFFv06_DCtx* ZBUFFv06_createDCtx(void)
39193919
if (zbd==NULL) return NULL;
39203920
memset(zbd, 0, sizeof(*zbd));
39213921
zbd->zd = ZSTDv06_createDCtx();
3922+
if (zbd->zd==NULL) {
3923+
ZBUFFv06_freeDCtx(zbd); /* avoid leaking the context */
3924+
return NULL;
3925+
}
39223926
zbd->stage = ZBUFFds_init;
39233927
return zbd;
39243928
}

0 commit comments

Comments
 (0)