summaryrefslogtreecommitdiffstats
path: root/gifalloc.c
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2017-03-13 14:23:58 -0400
committermse1969 <mse1969@posteo.de>2017-05-24 21:34:07 +0200
commit3923f809b866e06e79a3d2003c68d45be8461f1b (patch)
treeb6eb6e172c3bd5bd3446a279379e198b007f48f4 /gifalloc.c
parent9b8f8602a74a943ddc356bb11c55b4998b2b386d (diff)
downloadandroid_external_giflib-cm-13.0.tar.gz
android_external_giflib-cm-13.0.tar.bz2
android_external_giflib-cm-13.0.zip
Update GIFLIB to 5.1.4 DO NOT MERGEreplicant-6.0-0002cm-13.0
Bug:34697653 Also include <limits.h> in openbsd-reallocarray.c, which is where Android defines SIZE_MAX. Preserve Android modification in egif_lib.c, which changed "S_IREAD | S_IWRITE" to "S_IRUSR | S_IWUSR" AOSP-Change-Id: If19d3f071fd96afa2d37fe08d196c5042856c41b (cherry picked from commit 7eb1d41f601998ea9be3e7c2034b262ff263b862) CVE-2015-7555 Change-Id: Ie471001b442ee93a0072ba7292e425be580a4752
Diffstat (limited to 'gifalloc.c')
-rw-r--r--gifalloc.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/gifalloc.c b/gifalloc.c
index 4cb8cde..ffaea3f 100644
--- a/gifalloc.c
+++ b/gifalloc.c
@@ -187,8 +187,8 @@ GifUnionColorMap(const ColorMapObject *ColorIn1,
/* perhaps we can shrink the map? */
if (RoundUpTo < ColorUnion->ColorCount)
- ColorUnion->Colors = (GifColorType *)realloc(Map,
- sizeof(GifColorType) * RoundUpTo);
+ ColorUnion->Colors = (GifColorType *)reallocarray(Map,
+ RoundUpTo, sizeof(GifColorType));
}
ColorUnion->ColorCount = RoundUpTo;
@@ -225,9 +225,9 @@ GifAddExtensionBlock(int *ExtensionBlockCount,
if (*ExtensionBlocks == NULL)
*ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock));
else
- *ExtensionBlocks = (ExtensionBlock *)realloc(*ExtensionBlocks,
- sizeof(ExtensionBlock) *
- (*ExtensionBlockCount + 1));
+ *ExtensionBlocks = (ExtensionBlock *)reallocarray(*ExtensionBlocks,
+ (*ExtensionBlockCount + 1),
+ sizeof(ExtensionBlock));
if (*ExtensionBlocks == NULL)
return (GIF_ERROR);
@@ -316,8 +316,8 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
if (GifFile->SavedImages == NULL)
GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
else
- GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages,
- sizeof(SavedImage) * (GifFile->ImageCount + 1));
+ GifFile->SavedImages = (SavedImage *)reallocarray(GifFile->SavedImages,
+ (GifFile->ImageCount + 1), sizeof(SavedImage));
if (GifFile->SavedImages == NULL)
return ((SavedImage *)NULL);
@@ -346,9 +346,10 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
}
/* next, the raster */
- sp->RasterBits = (unsigned char *)malloc(sizeof(GifPixelType) *
- CopyFrom->ImageDesc.Height *
- CopyFrom->ImageDesc.Width);
+ sp->RasterBits = (unsigned char *)reallocarray(NULL,
+ (CopyFrom->ImageDesc.Height *
+ CopyFrom->ImageDesc.Width),
+ sizeof(GifPixelType));
if (sp->RasterBits == NULL) {
FreeLastSavedImage(GifFile);
return (SavedImage *)(NULL);
@@ -359,9 +360,10 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
/* finally, the extension blocks */
if (sp->ExtensionBlocks != NULL) {
- sp->ExtensionBlocks = (ExtensionBlock *)malloc(
- sizeof(ExtensionBlock) *
- CopyFrom->ExtensionBlockCount);
+ sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL,
+ CopyFrom->ExtensionBlockCount,
+ sizeof(ExtensionBlock));
+
if (sp->ExtensionBlocks == NULL) {
FreeLastSavedImage(GifFile);
return (SavedImage *)(NULL);