Commits

pajoye  committed 1dbbe05

#25, Added sanity checks for possible allocation failures in gdCacheCreate
and main

  • Participants
  • Parent commits 30a36c2

Comments (0)

Files changed (2)

 #20, Fixed gdImageCopyMergeGray when used with a true color image
 #21, gdImageCopyResized sanity check for allocation failures
 #22, Fixed transparency preservation in gdImageCopyRotated 
-#23,  Added sanity checks  for possible allocation failures in 
+#23, Added sanity checks for possible allocation failures in 
       gdImageFilledPolygon and gdImageSetStyle
-#24,  Out of range checks in gdImageSetAAPixelColor
+#24, Out of range checks in gdImageSetAAPixelColor
+#25, Added sanity checks for possible allocation failures in gdCacheCreate
+     and main

File src/gdcache.c

   gdCache_head_t *head;
 
   head = (gdCache_head_t *) gdMalloc (sizeof (gdCache_head_t));
+	if (!head) {
+		return NULL;
+	}
+
   head->mru = NULL;
   head->size = size;
   head->gdCacheTest = gdCacheTest;
   int elem, key;
 
   cacheTable = gdCacheCreate (3, cacheTest, cacheFetch, cacheRelease);
+	if (!cacheTable) {
+		exit(1);
+	}
 
   key = 20;
   elem = *(int *) gdCacheGet (cacheTable, &key);