facebook / zstd

Zstandard - Fast real-time compression algorithm
http://www.zstd.net
Other
23.42k stars 2.08k forks source link

[fix] Add check on failed allocation in legacy/zstd_v06 #4050

Closed Adenilson closed 4 months ago

Adenilson commented 4 months ago

As reported by Ben Hawkes in #4026, a failure to allocate a zstd context would lead to a dereference of a NULL pointer due to a missing check on the returned result of ZSTDv06_createDCtx().

This patch fix the issue by adding a check for valid returned pointer.

Adenilson commented 4 months ago

I'm trying to follow the same coding style used in: https://github.com/facebook/zstd/blob/dev/lib/legacy/zstd_v06.c#L3919

adenilsoncavalcanti commented 4 months ago

@Cyan4973 anything else you like to see changed in the patch? :-)

Cyan4973 commented 4 months ago

Nope, it's good!