Skip to content

Commit

Permalink
utils: Fix bad malloc result check in buffer_read_from_filename and t…
Browse files Browse the repository at this point in the history
…est arguments for NULL
  • Loading branch information
nikias committed Oct 19, 2021
1 parent 499a557 commit 7c37434
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ LIBIMOBILEDEVICE_GLUE_API int buffer_read_from_filename(const char *filename, ch
FILE *f;
uint64_t size;

if (!filename || !buffer || !length) {
return 0;
}

*length = 0;

f = fopen(filename, "rb");
Expand All @@ -275,7 +279,7 @@ LIBIMOBILEDEVICE_GLUE_API int buffer_read_from_filename(const char *filename, ch

*buffer = (char*)malloc(sizeof(char)*(size+1));

if (!buffer) {
if (*buffer == NULL) {
return 0;
}

Expand Down

0 comments on commit 7c37434

Please sign in to comment.