Check fread return value

This commit is contained in:
Jouni Malinen 2009-12-21 23:17:53 +02:00 committed by Jouni Malinen
parent 7bf127572c
commit a698d28415

View file

@ -206,7 +206,12 @@ char * os_readfile(const char *name, size_t *len)
return NULL; return NULL;
} }
fread(buf, 1, *len, f); if (fread(buf, 1, *len, f) != *len) {
fclose(f);
os_free(buf);
return NULL;
}
fclose(f); fclose(f);
return buf; return buf;