Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 637438
Collapse All | Expand All

(-)a/lib/dgif_lib.c (-2 / +2 lines)
Lines 396-402 DGifGetImageDesc(GifFileType *GifFile) Link Here
396
396
397
    if (GifFile->SavedImages) {
397
    if (GifFile->SavedImages) {
398
        SavedImage* new_saved_images =
398
        SavedImage* new_saved_images =
399
            (SavedImage *)reallocarray(GifFile->SavedImages,
399
            (SavedImage *)openbsd_reallocarray(GifFile->SavedImages,
400
                            (GifFile->ImageCount + 1), sizeof(SavedImage));
400
                            (GifFile->ImageCount + 1), sizeof(SavedImage));
401
        if (new_saved_images == NULL) {
401
        if (new_saved_images == NULL) {
402
            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
402
            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
Lines 1108-1114 DGifSlurp(GifFileType *GifFile) Link Here
1108
              if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
1108
              if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
1109
                  return GIF_ERROR;
1109
                  return GIF_ERROR;
1110
              }
1110
              }
1111
              sp->RasterBits = (unsigned char *)reallocarray(NULL, ImageSize,
1111
              sp->RasterBits = (unsigned char *)openbsd_reallocarray(NULL, ImageSize,
1112
                      sizeof(GifPixelType));
1112
                      sizeof(GifPixelType));
1113
1113
1114
              if (sp->RasterBits == NULL) {
1114
              if (sp->RasterBits == NULL) {
(-)a/lib/gif_lib.h (-3 lines)
Lines 244-252 extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1, Link Here
244
                                     GifPixelType ColorTransIn2[]);
244
                                     GifPixelType ColorTransIn2[]);
245
extern int GifBitSize(int n);
245
extern int GifBitSize(int n);
246
246
247
extern void *
248
reallocarray(void *optr, size_t nmemb, size_t size);
249
250
/******************************************************************************
247
/******************************************************************************
251
 Support for the in-core structures allocation (slurp mode).              
248
 Support for the in-core structures allocation (slurp mode).              
252
******************************************************************************/
249
******************************************************************************/
(-)a/lib/gifalloc.c (-5 / +5 lines)
Lines 188-194 GifUnionColorMap(const ColorMapObject *ColorIn1, Link Here
188
188
189
        /* perhaps we can shrink the map? */
189
        /* perhaps we can shrink the map? */
190
        if (RoundUpTo < ColorUnion->ColorCount) {
190
        if (RoundUpTo < ColorUnion->ColorCount) {
191
            GifColorType *new_map = (GifColorType *)reallocarray(Map,
191
            GifColorType *new_map = (GifColorType *)openbsd_reallocarray(Map,
192
                                 RoundUpTo, sizeof(GifColorType));
192
                                 RoundUpTo, sizeof(GifColorType));
193
            if( new_map == NULL ) {
193
            if( new_map == NULL ) {
194
                GifFreeMapObject(ColorUnion);
194
                GifFreeMapObject(ColorUnion);
Lines 232-238 GifAddExtensionBlock(int *ExtensionBlockCount, Link Here
232
    if (*ExtensionBlocks == NULL)
232
    if (*ExtensionBlocks == NULL)
233
        *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock));
233
        *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock));
234
    else {
234
    else {
235
        ExtensionBlock* ep_new = (ExtensionBlock *)reallocarray
235
        ExtensionBlock* ep_new = (ExtensionBlock *)openbsd_reallocarray
236
				 (*ExtensionBlocks, (*ExtensionBlockCount + 1),
236
				 (*ExtensionBlocks, (*ExtensionBlockCount + 1),
237
                                      sizeof(ExtensionBlock));
237
                                      sizeof(ExtensionBlock));
238
        if( ep_new == NULL )
238
        if( ep_new == NULL )
Lines 325-331 GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) Link Here
325
    if (GifFile->SavedImages == NULL)
325
    if (GifFile->SavedImages == NULL)
326
        GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
326
        GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
327
    else
327
    else
328
        GifFile->SavedImages = (SavedImage *)reallocarray(GifFile->SavedImages,
328
        GifFile->SavedImages = (SavedImage *)openbsd_reallocarray(GifFile->SavedImages,
329
                               (GifFile->ImageCount + 1), sizeof(SavedImage));
329
                               (GifFile->ImageCount + 1), sizeof(SavedImage));
330
330
331
    if (GifFile->SavedImages == NULL)
331
    if (GifFile->SavedImages == NULL)
Lines 355-361 GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) Link Here
355
            }
355
            }
356
356
357
            /* next, the raster */
357
            /* next, the raster */
358
            sp->RasterBits = (unsigned char *)reallocarray(NULL,
358
            sp->RasterBits = (unsigned char *)openbsd_reallocarray(NULL,
359
                                                  (CopyFrom->ImageDesc.Height *
359
                                                  (CopyFrom->ImageDesc.Height *
360
                                                  CopyFrom->ImageDesc.Width),
360
                                                  CopyFrom->ImageDesc.Width),
361
						  sizeof(GifPixelType));
361
						  sizeof(GifPixelType));
Lines 369-375 GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) Link Here
369
369
370
            /* finally, the extension blocks */
370
            /* finally, the extension blocks */
371
            if (sp->ExtensionBlocks != NULL) {
371
            if (sp->ExtensionBlocks != NULL) {
372
                sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL,
372
                sp->ExtensionBlocks = (ExtensionBlock *)openbsd_reallocarray(NULL,
373
                                      CopyFrom->ExtensionBlockCount,
373
                                      CopyFrom->ExtensionBlockCount,
374
				      sizeof(ExtensionBlock));
374
				      sizeof(ExtensionBlock));
375
                if (sp->ExtensionBlocks == NULL) {
375
                if (sp->ExtensionBlocks == NULL) {
(-)a/lib/openbsd-reallocarray.c (-2 / +1 lines)
Lines 27-33 Link Here
27
#define MUL_NO_OVERFLOW	((size_t)1 << (sizeof(size_t) * 4))
27
#define MUL_NO_OVERFLOW	((size_t)1 << (sizeof(size_t) * 4))
28
28
29
void *
29
void *
30
reallocarray(void *optr, size_t nmemb, size_t size)
30
openbsd_reallocarray(void *optr, size_t nmemb, size_t size)
31
{
31
{
32
	if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
32
	if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
33
	    nmemb > 0 && SIZE_MAX / nmemb < size) {
33
	    nmemb > 0 && SIZE_MAX / nmemb < size) {
34
- 

Return to bug 637438