mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-09 16:21:45 +00:00
Check for calloc() failure in filesystem code
This commit is contained in:
1 parent
4593332204
commit
f015a8686e
3 files changed
+20
-16
No files matched your search
+6
-5
@@ -73,12 +73,13 @@ static void *ff_open(const char *path, int flags) {
|
||||
unsigned char mode = FA_READ;
|
||||
if (flags & MG_FS_WRITE) mode |= FA_WRITE | FA_OPEN_ALWAYS | FA_OPEN_APPEND;
|
||||
if (f_open(&f, path, mode) == 0) {
|
||||
FIL *fp = calloc(1, sizeof(*fp));
|
||||
memcpy(fp, &f, sizeof(*fp));
|
||||
return fp;
|
||||
} else {
|
||||
return NULL;
|
||||
FIL *fp;
|
||||
if ((fp = calloc(1, sizeof(*fp))) != NULL) {
|
||||
memcpy(fp, &f, sizeof(*fp));
|
||||
return fp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ff_close(void *fp) {
|
||||
|
||||
Reference in new issue
Block a user