Check for calloc() failure in filesystem code

This commit is contained in:
Sergio R. Caprile committed 2023-04-27 11:19:02 -03:00
1 parent 4593332204
commit f015a8686e
3 files changed
+20 -16

No files matched your search

+4 -3
View File
@@ -67,9 +67,10 @@ static void *packed_open(const char *path, int flags) {
struct packed_file *fp = NULL;
if (data == NULL) return NULL;
if (flags & MG_FS_WRITE) return NULL;
fp = (struct packed_file *) calloc(1, sizeof(*fp));
fp->size = size;
fp->data = data;
if ((fp = (struct packed_file *) calloc(1, sizeof(*fp))) != NULL) {
fp->size = size;
fp->data = data;
}
return (void *) fp;
}