1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-29 11:21:22 +03:00

fixed malloc(0) potential issue

Added test cases to cover #556 patch
This commit is contained in:
Yann Collet
2017-02-22 11:08:00 -08:00
parent e68dbdaf67
commit 1f3d54ddb4
2 changed files with 13 additions and 6 deletions

View File

@ -35,7 +35,7 @@ static FILE* fopen_orDie(const char *filename, const char *instruction)
static void* malloc_orDie(size_t size)
{
void* const buff = malloc(size);
void* const buff = malloc(size + !size); /* avoid allocating size of 0 : may return NULL (implementation dependent) */
if (buff) return buff;
/* error */
fprintf(stderr, "malloc: %s \n", strerror(errno));