Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 276988 | Differences between
and this patch

Collapse All | Expand All

(-)tiff-3.8.2/tools/rgb2ycbcr.c (-2 / +20 lines)
Lines 34-39 Link Here
34
# include <unistd.h>
34
# include <unistd.h>
35
#endif
35
#endif
36
36
37
#include "tiffiop.h"
37
#include "tiffio.h"
38
#include "tiffio.h"
38
39
39
#define	streq(a,b)	(strcmp(a,b) == 0)
40
#define	streq(a,b)	(strcmp(a,b) == 0)
Lines 279-291 tiffcvt(TIFF* in, TIFF* out) Link Here
279
	char *stringv;
280
	char *stringv;
280
	uint32 longv;
281
	uint32 longv;
281
282
283
	size_t pixel_count;
282
	TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
284
	TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
283
	TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
285
	TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
284
	raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32));
286
	pixel_count = width * height;
287
288
	/* XXX: Check the integer overflow. */
289
	if (!width || !height || pixel_count / width != height) {
290
		TIFFError(TIFFFileName(in),
291
			  "Malformed input file; "
292
			  "can't allocate buffer for raster of %lux%lu size",
293
			  (unsigned long)width, (unsigned long)height);
294
		return 0;
295
	}
296
297
	raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32),
298
					   "raster buffer");
285
	if (raster == 0) {
299
	if (raster == 0) {
286
		TIFFError(TIFFFileName(in), "No space for raster buffer");
300
		TIFFError(TIFFFileName(in),
301
			  "Requested buffer size is %lu elements %lu each",
302
			  (unsigned long)pixel_count,
303
			  (unsigned long)sizeof(uint32));
287
		return (0);
304
		return (0);
288
	}
305
	}
306
289
	if (!TIFFReadRGBAImage(in, width, height, raster, 0)) {
307
	if (!TIFFReadRGBAImage(in, width, height, raster, 0)) {
290
		_TIFFfree(raster);
308
		_TIFFfree(raster);
291
		return (0);
309
		return (0);
(-)tiff-3.8.2/tools/tiff2rgba.c (-5 / +17 lines)
Lines 34-39 Link Here
34
# include <unistd.h>
34
# include <unistd.h>
35
#endif
35
#endif
36
36
37
#include "tiffiop.h"
37
#include "tiffio.h"
38
#include "tiffio.h"
38
39
39
#define	streq(a,b)	(strcmp(a,b) == 0)
40
#define	streq(a,b)	(strcmp(a,b) == 0)
Lines 328-343 cvt_whole_image( TIFF *in, TIFF *out ) Link Here
328
    uint32* raster;			/* retrieve RGBA image */
329
    uint32* raster;			/* retrieve RGBA image */
329
    uint32  width, height;		/* image width & height */
330
    uint32  width, height;		/* image width & height */
330
    uint32  row;
331
    uint32  row;
332
    size_t pixel_count;
331
        
333
        
332
    TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
334
    TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
333
    TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
335
    TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
336
    pixel_count = width * height;
337
338
    /* XXX: Check the integer overflow. */
339
    if (!width || !height || pixel_count / width != height) {
340
        TIFFError(TIFFFileName(in),
341
		  "Malformed input file; can't allocate buffer for raster of %lux%lu size",
342
		  (unsigned long)width, (unsigned long)height);
343
        return 0;
344
    }
334
345
335
    rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
346
    rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
336
    TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
347
    TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
337
348
338
    raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32));
349
    raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), "raster buffer");
339
    if (raster == 0) {
350
    if (raster == 0) {
340
        TIFFError(TIFFFileName(in), "No space for raster buffer");
351
        TIFFError(TIFFFileName(in), "Requested buffer size is %lu elements %lu each",
352
		  (unsigned long)pixel_count, (unsigned long)sizeof(uint32));
341
        return (0);
353
        return (0);
342
    }
354
    }
343
355
Lines 353-370 cvt_whole_image( TIFF *in, TIFF *out ) Link Here
353
    */
365
    */
354
    if( no_alpha )
366
    if( no_alpha )
355
    {
367
    {
356
        int	pixel_count = width * height;
368
        size_t count = pixel_count;
357
        unsigned char *src, *dst;
369
        unsigned char *src, *dst;
358
370
359
        src = (unsigned char *) raster;
371
        src = (unsigned char *) raster;
360
        dst = (unsigned char *) raster;
372
        dst = (unsigned char *) raster;
361
        while( pixel_count > 0 )
373
        while(count > 0)
362
        {
374
        {
363
            *(dst++) = *(src++);
375
            *(dst++) = *(src++);
364
            *(dst++) = *(src++);
376
            *(dst++) = *(src++);
365
            *(dst++) = *(src++);
377
            *(dst++) = *(src++);
366
            src++;
378
            src++;
367
            pixel_count--;
379
            count--;
368
        }
380
        }
369
    }
381
    }
370
382

Return to bug 276988