Handle ftell error, thanks to @disaykin

This commit is contained in:
Soner Tari 2023-05-18 00:34:37 +03:00
parent 3048f95485
commit 6a92058b09

View File

@ -93,6 +93,11 @@ dynbuf_new_file(const char *filename)
}
fseek(f, 0, SEEK_END);
db->sz = ftell(f);
if (db->sz == (size_t)-1) {
free(db);
fclose(f);
return NULL;
}
fseek(f, 0, SEEK_SET);
if (!(db->buf = malloc(db->sz))) {
free(db);