diff options
author | Nikias Bassen | 2021-10-19 02:50:34 +0200 |
---|---|---|
committer | Nikias Bassen | 2021-10-19 02:50:34 +0200 |
commit | 7c37434360f1c49975c286566efc3f0c935a84ef (patch) | |
tree | 04f89c587c3fd5a02f46c38526e7288c3be2c4f3 /src | |
parent | 499a5578b15235d00bc492068635de45bec1807d (diff) | |
download | libimobiledevice-glue-7c37434360f1c49975c286566efc3f0c935a84ef.tar.gz libimobiledevice-glue-7c37434360f1c49975c286566efc3f0c935a84ef.tar.bz2 |
utils: Fix bad malloc result check in buffer_read_from_filename and test arguments for NULL
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c index b03f13b..7b10a08 100644 --- a/src/utils.c +++ b/src/utils.c @@ -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"); @@ -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; } |