diff --git a/xdgmimemagic.cpp b/xdgmimemagic.cpp index b4f9e14d9..3f67b2906 100644 --- a/xdgmimemagic.cpp +++ b/xdgmimemagic.cpp @@ -183,7 +183,13 @@ _xdg_mime_magic_read_to_newline(FILE *magic_file, if (pos % 128 == 127) { len = len + 128; - retval = (char *)realloc(retval, len); + char *tmp = (char *)realloc(retval, len); + if (tmp == NULL) + { + free(retval); + return NULL; + } + retval = tmp; } }