don't rely on malloc to handle (0) parameter; abort before.
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 29 Sep 2013 18:11:50 +0000 (20:11 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 29 Sep 2013 18:11:50 +0000 (20:11 +0200)
libcitadel/lib/xdgmime/xdgmimecache.c

index d5eae935f64d1d7d31d30e544311ae518d6ae1e0..f544cf41210fc2f0cdb9f2da7892363ee9b06e83 100644 (file)
@@ -709,6 +709,8 @@ _xdg_mime_cache_get_mime_type_for_file (const char  *file_name,
    * be large and need getting from a stream instead of just reading it all
    * in. */
   max_extent = _xdg_mime_cache_get_max_buffer_extents ();
+  if (max_extent == 0)
+    return XDG_MIME_TYPE_UNKNOWN;
   data = malloc (max_extent);
   if (data == NULL)
     return XDG_MIME_TYPE_UNKNOWN;