~ubuntu-branches/ubuntu/maverick/libpng/maverick-security

« back to all changes in this revision

Viewing changes to pngrutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2009-12-04 11:23:50 UTC
  • mfrom: (1.1.10 upstream) (15.2.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091204112350-ln22xyakgn9bh39k
Tags: 1.2.41-1
* New upstream release
* Debian source format is 3.0 (quilt)
* Update debian/watch
* Add 02-export-png_set_strip_error_numbers.patch
  Define PNG_ERROR_NUMBERS_SUPPORTED
  Upstream doesn't define PNG_ERROR_NUMBERS_SUPPORTED since 1.2.41. As
  a consecuence, the symbol png_set_strip_error_numbe@@PNG12_0 wasn't
  exported.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/* pngrutil.c - utilities to read a PNG file
3
3
 *
4
 
 * Last changed in libpng 1.2.38 [July 16, 2009]
 
4
 * Last changed in libpng 1.2.41 [December 3, 2009]
5
5
 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
6
6
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7
7
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
15
15
 */
16
16
 
17
17
#define PNG_INTERNAL
 
18
#define PNG_NO_PEDANTIC_WARNINGS
18
19
#include "png.h"
19
 
#if defined(PNG_READ_SUPPORTED)
 
20
#ifdef PNG_READ_SUPPORTED
20
21
 
21
22
#if defined(_WIN32_WCE) && (_WIN32_WCE<0x500)
22
23
#  define WIN32_WCE_OLD
23
24
#endif
24
25
 
25
26
#ifdef PNG_FLOATING_POINT_SUPPORTED
26
 
#  if defined(WIN32_WCE_OLD)
 
27
#  ifdef WIN32_WCE_OLD
27
28
/* The strtod() function is not supported on WindowsCE */
28
29
__inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr)
29
30
{
228
229
                              png_size_t chunklength,
229
230
                              png_size_t prefix_size, png_size_t *newlength)
230
231
{
231
 
   static PNG_CONST char msg[] = "Error decoding compressed text";
 
232
   static PNG_CONST char msg[] = "Error decoding compressed chunk";
232
233
   png_charp text;
233
234
   png_size_t text_size;
234
235
 
302
303
               png_charp tmp;
303
304
 
304
305
               tmp = text;
305
 
               text = (png_charp)png_malloc_warn(png_ptr,
306
 
                  (png_uint_32)(text_size +
307
 
                  png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
 
306
                  text = (png_charp)png_malloc_warn(png_ptr,
 
307
                     (png_uint_32)(text_size +
 
308
                      png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
308
309
               if (text == NULL)
309
310
               {
310
311
                  png_free(png_ptr, tmp);
331
332
      }
332
333
      if (ret != Z_STREAM_END)
333
334
      {
334
 
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
 
335
#if defined(PNG_STDIO_SUPPORTED) && !defined(_WIN32_WCE)
335
336
         char umsg[52];
336
337
 
337
338
         if (ret == Z_BUF_ERROR)
378
379
   }
379
380
   else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */
380
381
   {
381
 
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
 
382
#if defined(PNG_STDIO_SUPPORTED) && !defined(_WIN32_WCE)
382
383
      char umsg[50];
383
384
 
384
385
      png_snprintf(umsg, 50, "Unknown zTXt compression type %d", comp_type);
430
431
   png_ptr->bit_depth = (png_byte)bit_depth;
431
432
   png_ptr->interlaced = (png_byte)interlace_type;
432
433
   png_ptr->color_type = (png_byte)color_type;
433
 
#if defined(PNG_MNG_FEATURES_SUPPORTED)
 
434
#ifdef PNG_MNG_FEATURES_SUPPORTED
434
435
   png_ptr->filter_type = (png_byte)filter_type;
435
436
#endif
436
437
   png_ptr->compression_type = (png_byte)compression_type;
473
474
{
474
475
   png_color palette[PNG_MAX_PALETTE_LENGTH];
475
476
   int num, i;
476
 
#ifndef PNG_NO_POINTER_INDEXING
 
477
#ifdef PNG_POINTER_INDEXING_SUPPORTED
477
478
   png_colorp pal_ptr;
478
479
#endif
479
480
 
501
502
      png_crc_finish(png_ptr, length);
502
503
      return;
503
504
   }
504
 
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
 
505
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
505
506
   if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
506
507
   {
507
508
      png_crc_finish(png_ptr, length);
526
527
 
527
528
   num = (int)length / 3;
528
529
 
529
 
#ifndef PNG_NO_POINTER_INDEXING
 
530
#ifdef PNG_POINTER_INDEXING_SUPPORTED
530
531
   for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
531
532
   {
532
533
      png_byte buf[3];
554
555
    * have an RGB image, the PLTE can be considered ancillary, so
555
556
    * we will act as though it is.
556
557
    */
557
 
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
 
558
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
558
559
   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
559
560
#endif
560
561
   {
561
562
      png_crc_finish(png_ptr, 0);
562
563
   }
563
 
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
 
564
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
564
565
   else if (png_crc_error(png_ptr))  /* Only if we have a CRC error */
565
566
   {
566
567
      /* If we don't want to use the data from an ancillary chunk,
589
590
 
590
591
   png_set_PLTE(png_ptr, info_ptr, palette, num);
591
592
 
592
 
#if defined(PNG_READ_tRNS_SUPPORTED)
 
593
#ifdef PNG_READ_tRNS_SUPPORTED
593
594
   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
594
595
   {
595
596
      if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
631
632
   info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
632
633
}
633
634
 
634
 
#if defined(PNG_READ_gAMA_SUPPORTED)
 
635
#ifdef PNG_READ_gAMA_SUPPORTED
635
636
void /* PRIVATE */
636
637
png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
637
638
{
656
657
      png_warning(png_ptr, "Out of place gAMA chunk");
657
658
 
658
659
   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
659
 
#if defined(PNG_READ_sRGB_SUPPORTED)
 
660
#ifdef PNG_READ_sRGB_SUPPORTED
660
661
      && !(info_ptr->valid & PNG_INFO_sRGB)
661
662
#endif
662
663
      )
686
687
         return;
687
688
      }
688
689
 
689
 
#if defined(PNG_READ_sRGB_SUPPORTED)
 
690
#ifdef PNG_READ_sRGB_SUPPORTED
690
691
   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
691
692
      if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
692
693
      {
693
694
         png_warning(png_ptr,
694
695
           "Ignoring incorrect gAMA value when sRGB is also present");
695
 
#ifndef PNG_NO_CONSOLE_IO
 
696
#ifdef PNG_CONSOLE_IO_SUPPORTED
696
697
         fprintf(stderr, "gamma = (%d/100000)", (int)igamma);
697
698
#endif
698
699
         return;
712
713
}
713
714
#endif
714
715
 
715
 
#if defined(PNG_READ_sBIT_SUPPORTED)
 
716
#ifdef PNG_READ_sBIT_SUPPORTED
716
717
void /* PRIVATE */
717
718
png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
718
719
{
778
779
}
779
780
#endif
780
781
 
781
 
#if defined(PNG_READ_cHRM_SUPPORTED)
 
782
#ifdef PNG_READ_cHRM_SUPPORTED
782
783
void /* PRIVATE */
783
784
png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
784
785
{
806
807
      png_warning(png_ptr, "Missing PLTE before cHRM");
807
808
 
808
809
   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
809
 
#if defined(PNG_READ_sRGB_SUPPORTED)
 
810
#ifdef PNG_READ_sRGB_SUPPORTED
810
811
      && !(info_ptr->valid & PNG_INFO_sRGB)
811
812
#endif
812
813
      )
858
859
   blue_y  = (float)int_y_blue  / (float)100000.0;
859
860
#endif
860
861
 
861
 
#if defined(PNG_READ_sRGB_SUPPORTED)
 
862
#ifdef PNG_READ_sRGB_SUPPORTED
862
863
   if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB))
863
864
      {
864
865
      if (PNG_OUT_OF_RANGE(int_x_white, 31270,  1000) ||
872
873
         {
873
874
            png_warning(png_ptr,
874
875
              "Ignoring incorrect cHRM value when sRGB is also present");
875
 
#ifndef PNG_NO_CONSOLE_IO
 
876
#ifdef PNG_CONSOLE_IO_SUPPORTED
876
877
#ifdef PNG_FLOATING_POINT_SUPPORTED
877
878
            fprintf(stderr, "wx=%f, wy=%f, rx=%f, ry=%f\n",
878
879
               white_x, white_y, red_x, red_y);
884
885
            fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
885
886
               int_x_green, int_y_green, int_x_blue, int_y_blue);
886
887
#endif
887
 
#endif /* PNG_NO_CONSOLE_IO */
 
888
#endif /* PNG_CONSOLE_IO_SUPPORTED */
888
889
         }
889
890
         return;
890
891
      }
902
903
}
903
904
#endif
904
905
 
905
 
#if defined(PNG_READ_sRGB_SUPPORTED)
 
906
#ifdef PNG_READ_sRGB_SUPPORTED
906
907
void /* PRIVATE */
907
908
png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
908
909
{
964
965
      {
965
966
         png_warning(png_ptr,
966
967
           "Ignoring incorrect gAMA value when sRGB is also present");
967
 
#ifndef PNG_NO_CONSOLE_IO
 
968
#ifdef PNG_CONSOLE_IO_SUPPORTED
968
969
#  ifdef PNG_FIXED_POINT_SUPPORTED
969
970
         fprintf(stderr, "incorrect gamma=(%d/100000)\n",
970
971
            (int)png_ptr->int_gamma);
1000
1001
}
1001
1002
#endif /* PNG_READ_sRGB_SUPPORTED */
1002
1003
 
1003
 
#if defined(PNG_READ_iCCP_SUPPORTED)
 
1004
#ifdef PNG_READ_iCCP_SUPPORTED
1004
1005
void /* PRIVATE */
1005
1006
png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1006
1007
/* Note: this does not properly handle chunks that are > 64K under DOS */
1120
1121
}
1121
1122
#endif /* PNG_READ_iCCP_SUPPORTED */
1122
1123
 
1123
 
#if defined(PNG_READ_sPLT_SUPPORTED)
 
1124
#ifdef PNG_READ_sPLT_SUPPORTED
1124
1125
void /* PRIVATE */
1125
1126
png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1126
1127
/* Note: this does not properly handle chunks that are > 64K under DOS */
1127
1128
{
1128
1129
   png_bytep entry_start;
1129
1130
   png_sPLT_t new_palette;
1130
 
#ifdef PNG_NO_POINTER_INDEXING
 
1131
#ifdef PNG_POINTER_INDEXING_SUPPORTED
1131
1132
   png_sPLT_entryp pp;
1132
1133
#endif
1133
1134
   int data_length, entry_size, i;
1136
1137
 
1137
1138
   png_debug(1, "in png_handle_sPLT");
1138
1139
 
1139
 
 
1140
1140
   if (!(png_ptr->mode & PNG_HAVE_IHDR))
1141
1141
      png_error(png_ptr, "Missing IHDR before sPLT");
1142
1142
   else if (png_ptr->mode & PNG_HAVE_IDAT)
1210
1210
       return;
1211
1211
   }
1212
1212
 
1213
 
#ifndef PNG_NO_POINTER_INDEXING
 
1213
#ifdef PNG_POINTER_INDEXING_SUPPORTED
1214
1214
   for (i = 0; i < new_palette.nentries; i++)
1215
1215
   {
1216
 
      png_sPLT_entryp pp = new_palette.entries + i;
 
1216
      pp = new_palette.entries + i;
1217
1217
 
1218
1218
      if (new_palette.depth == 8)
1219
1219
      {
1265
1265
}
1266
1266
#endif /* PNG_READ_sPLT_SUPPORTED */
1267
1267
 
1268
 
#if defined(PNG_READ_tRNS_SUPPORTED)
 
1268
#ifdef PNG_READ_tRNS_SUPPORTED
1269
1269
void /* PRIVATE */
1270
1270
png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1271
1271
{
1360
1360
}
1361
1361
#endif
1362
1362
 
1363
 
#if defined(PNG_READ_bKGD_SUPPORTED)
 
1363
#ifdef PNG_READ_bKGD_SUPPORTED
1364
1364
void /* PRIVATE */
1365
1365
png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1366
1366
{
1449
1449
}
1450
1450
#endif
1451
1451
 
1452
 
#if defined(PNG_READ_hIST_SUPPORTED)
 
1452
#ifdef PNG_READ_hIST_SUPPORTED
1453
1453
void /* PRIVATE */
1454
1454
png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1455
1455
{
1503
1503
}
1504
1504
#endif
1505
1505
 
1506
 
#if defined(PNG_READ_pHYs_SUPPORTED)
 
1506
#ifdef PNG_READ_pHYs_SUPPORTED
1507
1507
void /* PRIVATE */
1508
1508
png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1509
1509
{
1546
1546
}
1547
1547
#endif
1548
1548
 
1549
 
#if defined(PNG_READ_oFFs_SUPPORTED)
 
1549
#ifdef PNG_READ_oFFs_SUPPORTED
1550
1550
void /* PRIVATE */
1551
1551
png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1552
1552
{
1589
1589
}
1590
1590
#endif
1591
1591
 
1592
 
#if defined(PNG_READ_pCAL_SUPPORTED)
 
1592
#ifdef PNG_READ_pCAL_SUPPORTED
1593
1593
/* Read the pCAL chunk (described in the PNG Extensions document) */
1594
1594
void /* PRIVATE */
1595
1595
png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1723
1723
}
1724
1724
#endif
1725
1725
 
1726
 
#if defined(PNG_READ_sCAL_SUPPORTED)
 
1726
#ifdef PNG_READ_sCAL_SUPPORTED
1727
1727
/* Read the sCAL chunk */
1728
1728
void /* PRIVATE */
1729
1729
png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1866
1866
}
1867
1867
#endif
1868
1868
 
1869
 
#if defined(PNG_READ_tIME_SUPPORTED)
 
1869
#ifdef PNG_READ_tIME_SUPPORTED
1870
1870
void /* PRIVATE */
1871
1871
png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1872
1872
{
1909
1909
}
1910
1910
#endif
1911
1911
 
1912
 
#if defined(PNG_READ_tEXt_SUPPORTED)
 
1912
#ifdef PNG_READ_tEXt_SUPPORTED
1913
1913
/* Note: this does not properly handle chunks that are > 64K under DOS */
1914
1914
void /* PRIVATE */
1915
1915
png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1923
1923
 
1924
1924
   png_debug(1, "in png_handle_tEXt");
1925
1925
 
1926
 
 
1927
1926
   if (!(png_ptr->mode & PNG_HAVE_IHDR))
1928
1927
      png_error(png_ptr, "Missing IHDR before tEXt");
1929
1928
 
1996
1995
}
1997
1996
#endif
1998
1997
 
1999
 
#if defined(PNG_READ_zTXt_SUPPORTED)
 
1998
#ifdef PNG_READ_zTXt_SUPPORTED
2000
1999
/* Note: this does not correctly handle chunks that are > 64K under DOS */
2001
2000
void /* PRIVATE */
2002
2001
png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
2009
2008
 
2010
2009
   png_debug(1, "in png_handle_zTXt");
2011
2010
 
2012
 
 
2013
2011
   if (!(png_ptr->mode & PNG_HAVE_IHDR))
2014
2012
      png_error(png_ptr, "Missing IHDR before zTXt");
2015
2013
 
2100
2098
}
2101
2099
#endif
2102
2100
 
2103
 
#if defined(PNG_READ_iTXt_SUPPORTED)
 
2101
#ifdef PNG_READ_iTXt_SUPPORTED
2104
2102
/* Note: this does not correctly handle chunks that are > 64K under DOS */
2105
2103
void /* PRIVATE */
2106
2104
png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
2114
2112
 
2115
2113
   png_debug(1, "in png_handle_iTXt");
2116
2114
 
2117
 
 
2118
2115
   if (!(png_ptr->mode & PNG_HAVE_IHDR))
2119
2116
      png_error(png_ptr, "Missing IHDR before iTXt");
2120
2117
 
2242
2239
 
2243
2240
   png_debug(1, "in png_handle_unknown");
2244
2241
 
2245
 
 
2246
2242
   if (png_ptr->mode & PNG_HAVE_IDAT)
2247
2243
   {
2248
2244
#ifdef PNG_USE_LOCAL_ARRAYS
2254
2250
 
2255
2251
   if (!(png_ptr->chunk_name[0] & 0x20))
2256
2252
   {
2257
 
#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
 
2253
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
2258
2254
      if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
2259
2255
           PNG_HANDLE_CHUNK_ALWAYS
2260
 
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
 
2256
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
2261
2257
           && png_ptr->read_user_chunk_fn == NULL
2262
2258
#endif
2263
2259
        )
2265
2261
          png_chunk_error(png_ptr, "unknown critical chunk");
2266
2262
   }
2267
2263
 
2268
 
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
 
2264
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
2269
2265
   if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
2270
 
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
 
2266
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
2271
2267
       || (png_ptr->read_user_chunk_fn != NULL)
2272
2268
#endif
2273
2269
        )
2292
2288
         png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
2293
2289
         png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
2294
2290
       }
2295
 
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
 
2291
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
2296
2292
       if (png_ptr->read_user_chunk_fn != NULL)
2297
2293
       {
2298
2294
          /* Callback to user unknown chunk handler */
2304
2300
          if (ret == 0)
2305
2301
          {
2306
2302
             if (!(png_ptr->chunk_name[0] & 0x20))
2307
 
#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
 
2303
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
2308
2304
                if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
2309
2305
                     PNG_HANDLE_CHUNK_ALWAYS)
2310
2306
#endif
2325
2321
 
2326
2322
   png_crc_finish(png_ptr, skip);
2327
2323
 
2328
 
#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
 
2324
#ifndef PNG_READ_USER_CHUNKS_SUPPORTED
2329
2325
   info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
2330
2326
#endif
2331
2327
}
2383
2379
            png_uint_32 i;
2384
2380
            png_uint_32 row_width = png_ptr->width;
2385
2381
 
2386
 
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
 
2382
#ifdef PNG_READ_PACKSWAP_SUPPORTED
2387
2383
            if (png_ptr->transformations & PNG_PACKSWAP)
2388
2384
            {
2389
2385
                s_start = 0;
2438
2434
            png_uint_32 row_width = png_ptr->width;
2439
2435
            int value;
2440
2436
 
2441
 
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
 
2437
#ifdef PNG_READ_PACKSWAP_SUPPORTED
2442
2438
            if (png_ptr->transformations & PNG_PACKSWAP)
2443
2439
            {
2444
2440
               s_start = 0;
2490
2486
            png_uint_32 row_width = png_ptr->width;
2491
2487
            int value;
2492
2488
 
2493
 
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
 
2489
#ifdef PNG_READ_PACKSWAP_SUPPORTED
2494
2490
            if (png_ptr->transformations & PNG_PACKSWAP)
2495
2491
            {
2496
2492
               s_start = 0;
2573
2569
   png_bytep row = png_ptr->row_buf + 1;
2574
2570
   int pass = png_ptr->pass;
2575
2571
   png_uint_32 transformations = png_ptr->transformations;
2576
 
#ifdef PNG_USE_LOCAL_ARRAYS
2577
2572
   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
2578
2573
   /* Offset to next interlace block */
2579
2574
   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
2580
 
#endif
2581
2575
 
2582
2576
   png_debug(1, "in png_do_read_interlace");
2583
2577
   if (row != NULL && row_info != NULL)
2599
2593
            png_uint_32 i;
2600
2594
            int j;
2601
2595
 
2602
 
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
 
2596
#ifdef PNG_READ_PACKSWAP_SUPPORTED
2603
2597
            if (transformations & PNG_PACKSWAP)
2604
2598
            {
2605
2599
                sshift = (int)((row_info->width + 7) & 0x07);
2652
2646
            int jstop = png_pass_inc[pass];
2653
2647
            png_uint_32 i;
2654
2648
 
2655
 
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
 
2649
#ifdef PNG_READ_PACKSWAP_SUPPORTED
2656
2650
            if (transformations & PNG_PACKSWAP)
2657
2651
            {
2658
2652
               sshift = (int)(((row_info->width + 3) & 0x03) << 1);
2708
2702
            png_uint_32 i;
2709
2703
            int jstop = png_pass_inc[pass];
2710
2704
 
2711
 
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
 
2705
#ifdef PNG_READ_PACKSWAP_SUPPORTED
2712
2706
            if (transformations & PNG_PACKSWAP)
2713
2707
            {
2714
2708
               sshift = (int)(((row_info->width + 1) & 0x01) << 2);
2782
2776
      row_info->width = final_width;
2783
2777
      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
2784
2778
   }
2785
 
#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
 
2779
#ifndef PNG_READ_PACKSWAP_SUPPORTED
2786
2780
   transformations = transformations; /* Silence compiler warning */
2787
2781
#endif
2788
2782
}
2911
2905
   }
2912
2906
}
2913
2907
 
2914
 
#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
 
2908
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
2915
2909
void /* PRIVATE */
2916
2910
png_read_finish_row(png_structp png_ptr)
2917
2911
{
2918
 
#ifdef PNG_USE_LOCAL_ARRAYS
2919
2912
#ifdef PNG_READ_INTERLACING_SUPPORTED
2920
2913
   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
2921
2914
 
2931
2924
   /* Offset to next interlace block in the y direction */
2932
2925
   PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
2933
2926
#endif /* PNG_READ_INTERLACING_SUPPORTED */
2934
 
#endif
2935
2927
 
2936
2928
   png_debug(1, "in png_read_finish_row");
2937
2929
   png_ptr->row_number++;
3043
3035
 
3044
3036
   png_ptr->mode |= PNG_AFTER_IDAT;
3045
3037
}
3046
 
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
 
3038
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
3047
3039
 
3048
3040
void /* PRIVATE */
3049
3041
png_read_start_row(png_structp png_ptr)
3050
3042
{
3051
 
#ifdef PNG_USE_LOCAL_ARRAYS
3052
3043
#ifdef PNG_READ_INTERLACING_SUPPORTED
3053
3044
   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
3054
3045
 
3064
3055
   /* Offset to next interlace block in the y direction */
3065
3056
   PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
3066
3057
#endif
3067
 
#endif
3068
3058
 
3069
3059
   int max_pixel_depth;
3070
3060
   png_size_t row_bytes;
3098
3088
   }
3099
3089
   max_pixel_depth = png_ptr->pixel_depth;
3100
3090
 
3101
 
#if defined(PNG_READ_PACK_SUPPORTED)
 
3091
#ifdef PNG_READ_PACK_SUPPORTED
3102
3092
   if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8)
3103
3093
      max_pixel_depth = 8;
3104
3094
#endif
3105
3095
 
3106
 
#if defined(PNG_READ_EXPAND_SUPPORTED)
 
3096
#ifdef PNG_READ_EXPAND_SUPPORTED
3107
3097
   if (png_ptr->transformations & PNG_EXPAND)
3108
3098
   {
3109
3099
      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
3131
3121
   }
3132
3122
#endif
3133
3123
 
3134
 
#if defined(PNG_READ_FILLER_SUPPORTED)
 
3124
#ifdef PNG_READ_FILLER_SUPPORTED
3135
3125
   if (png_ptr->transformations & (PNG_FILLER))
3136
3126
   {
3137
3127
      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
3153
3143
   }
3154
3144
#endif
3155
3145
 
3156
 
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
 
3146
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
3157
3147
   if (png_ptr->transformations & PNG_GRAY_TO_RGB)
3158
3148
   {
3159
3149
      if (
3160
 
#if defined(PNG_READ_EXPAND_SUPPORTED)
 
3150
#ifdef PNG_READ_EXPAND_SUPPORTED
3161
3151
        (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) ||
3162
3152
#endif
3163
 
#if defined(PNG_READ_FILLER_SUPPORTED)
 
3153
#ifdef PNG_READ_FILLER_SUPPORTED
3164
3154
        (png_ptr->transformations & (PNG_FILLER)) ||
3165
3155
#endif
3166
3156
        png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
3215
3205
   if (row_bytes + 64 > png_ptr->old_big_row_buf_size)
3216
3206
   {
3217
3207
     png_free(png_ptr, png_ptr->big_row_buf);
3218
 
     png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 64);
3219
3208
     if (png_ptr->interlaced)
3220
 
       png_memset(png_ptr->big_row_buf, 0, row_bytes + 64);
 
3209
        png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, row_bytes + 64);
 
3210
     else
 
3211
        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 64);
3221
3212
     png_ptr->row_buf = png_ptr->big_row_buf + 32;
3222
3213
     png_ptr->old_big_row_buf_size = row_bytes + 64;
3223
3214
   }