Imported Upstream version 5.1.9 into tizen 63/223763/1
authorjiyong.min <jiyong.min@samsung.com>
Mon, 3 Feb 2020 06:52:19 +0000 (15:52 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Tue, 4 Feb 2020 00:49:35 +0000 (09:49 +0900)
Change-Id: I68f6b51063d39f2c94cd9e42968033dc60f2508d

1  2 
gif2rgb.c
gifbg.c
gifbuild.c
gifclrmp.c
gifcolor.c
gifecho.c
giffix.c
gifhisto.c
gifinto.c
giftext.c
gifwedge.c

diff --combined gif2rgb.c
+++ b/gif2rgb.c
@@@ -36,9 -36,8 +36,9 @@@ with our utilities mainly interesting a
  
  #define PROGRAM_NAME  "gif2rgb"
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -96,7 -95,6 +96,6 @@@ static void LoadRGB(char *FileName
  
            for (i = 0; i < 3; i++) {
                strncpy(OneFileName, FileName, sizeof(OneFileName)-1);
-               /* cppcheck-suppress uninitstring */
                strncat(OneFileName, Postfixes[i], 
                        sizeof(OneFileName) - 1 - strlen(OneFileName));
  
        }
  
        fclose(rgbfp[0]);
-       // cppcheck-suppress useClosedFile
        fclose(rgbfp[1]);
-       // cppcheck-suppress useClosedFile
        fclose(rgbfp[2]);
      }
  }
@@@ -179,13 -175,10 +176,10 @@@ static void SaveGif(GifByteType *Output
                          Width, Height, ExpColorMapSize, 0,
                          OutputColorMap) == GIF_ERROR ||
        EGifPutImageDesc(GifFile,
-                        0, 0, Width, Height, false, NULL) ==
-                                                                    GIF_ERROR)
+                        0, 0, Width, Height, false, NULL) == GIF_ERROR) {
        PrintGifError(Error);
-       if (GifFile != NULL) {
-           EGifCloseFile(GifFile, NULL);
-       }
        exit(EXIT_FAILURE);
+     }
  
      GifQprintf("\n%s: Image 1 at (%d, %d) [%dx%d]:     ",
               PROGRAM_NAME, GifFile->Image.Left, GifFile->Image.Top,
  
      for (i = 0; i < Height; i++) {
        if (EGifPutLine(GifFile, Ptr, Width) == GIF_ERROR)
-       {
-           if (GifFile != NULL) {
-               EGifCloseFile(GifFile, NULL);
-           }
            exit(EXIT_FAILURE);
-       }
        GifQprintf("\b\b\b\b%-4d", Height - i - 1);
  
        Ptr += Width;
      }
  
-     if (EGifCloseFile(GifFile, &Error) == GIF_ERROR)
+     if (EGifCloseFile(GifFile, &Error) == GIF_ERROR) {
        PrintGifError(Error);
-       if (GifFile != NULL) {
-           EGifCloseFile(GifFile, NULL);
-       }
        exit(EXIT_FAILURE);
+     }
  }
  
  /******************************************************************************
@@@ -274,7 -260,6 +261,6 @@@ static void DumpScreen2RGB(char *FileNa
  
              for (i = 0; i < 3; i++) {
                  strncpy(OneFileName, FileName, sizeof(OneFileName)-1);
-               /* cppcheck-suppress uninitstring */
                  strncat(OneFileName, Postfixes[i], 
                        sizeof(OneFileName) - 1 - strlen(OneFileName));
      
          rgbfp[0] = stdout;
      }
  
+     if (ColorMap == NULL) {
+       fprintf(stderr, "Color map pointer is NULL.\n");
+       exit(EXIT_FAILURE);
+     }
      if (OneFileFlag) {
          unsigned char *Buffer, *BufferP;
  
          free((char *) Buffers[1]);
          free((char *) Buffers[2]);
          fclose(rgbfp[0]);
-       // cppcheck-suppress useClosedFile
          fclose(rgbfp[1]);
-       // cppcheck-suppress useClosedFile
          fclose(rgbfp[2]);
      }
  }
@@@ -379,6 -367,11 +368,11 @@@ static void GIF2RGB(int NumFiles, char 
        }
      }
  
+     if (GifFile->SHeight == 0 || GifFile->SWidth == 0) {
+       fprintf(stderr, "Image of width or height 0\n");
+       exit(EXIT_FAILURE);
+     }
      /* 
       * Allocate the screen as vector of column of rows. Note this
       * screen is device independent - it's the screen defined by the
                break;
        }
      } while (RecordType != TERMINATE_RECORD_TYPE);
+     
      /* Lets dump it - set the global variables required and do it: */
      ColorMap = (GifFile->Image.ColorMap
                ? GifFile->Image.ColorMap
diff --combined gifbg.c
+++ b/gifbg.c
@@@ -39,9 -39,8 +39,9 @@@ gifbg - generate a test-pattern GI
  
  #define DEFAULT_DIR   "T"                        /* TOP (North) direction. */
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -71,7 -70,6 +71,6 @@@ static void QuitGifError(GifFileType *G
  ******************************************************************************/
  int main(int argc, char **argv)
  {
-     unsigned int Ratio;
      int       i, l, LevelWidth, LogNumLevels, ErrorCode, Count = 0;
      bool Error, FlipDir, DoAllMaximum = false,
        DirectionFlag = false, LevelsFlag = false, ColorFlag = false,
            break;
      }
      if (Direction == DIR_NONE)
-       GIF_EXIT("Direction requested (-d option) is wierd!");
+       GIF_EXIT("Direction requested (-d option) is weird!");
  
      /* We are going to handle only TOP, TOP_RIGHT, RIGHT, BOT_RIGHT  so flip */
      /* the complement cases (TOP <-> BOT for example) by flipping the      */
  
      for (i = 1; i <= NumLevels; i++) {
        /* Ratio will be in the range of 0..100 for required intensity: */
-       Ratio = (MaximumIntensity * (i * (256 / NumLevels)) +
-                MinimumIntensity * ((NumLevels - i) * (256 / NumLevels))) /
-                256;
+       unsigned int Ratio = (MaximumIntensity * (i * (256 / NumLevels)) +
+                             MinimumIntensity * ((NumLevels - i) * (256 / NumLevels))) /
+           256;
        ColorMap->Colors[i-1].Red   = (RedColor * Ratio) / 100;
        ColorMap->Colors[i-1].Green = (GreenColor * Ratio) / 100;
        ColorMap->Colors[i-1].Blue  = (BlueColor * Ratio) / 100;
      if (EGifCloseFile(GifFile, &ErrorCode) == GIF_ERROR)
      {
        PrintGifError(ErrorCode);
-       if (GifFile != NULL) {
-           EGifCloseFile(GifFile, NULL);
-       }
        exit(EXIT_FAILURE);
      }
  
diff --combined gifbuild.c
@@@ -16,9 -16,8 +16,9 @@@ gifbuild - dump GIF data in a textual f
  
  #define PROGRAM_NAME  "gifbuild"
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Eric Raymond,   "
@@@ -171,15 -170,12 +171,12 @@@ static void Icon2Gif(char *FileName, FI
         * Explicit header declarations
         */
  
-       // cppcheck-suppress invalidscanf 
        if (sscanf(buf, "screen width %d\n", &GifFileOut->SWidth) == 1)
            continue;
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "screen height %d\n", &GifFileOut->SHeight) == 1)
            continue;
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "screen colors %d\n", &n) == 1)
        {
            int ResBits = GifBitSize(n);
            continue;
        }
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf,
                        "screen background %d\n",
                        &GifFileOut->SBackGroundColor) == 1)
            continue;
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "pixel aspect byte %u\n", &intval) == 1) {
            GifFileOut->AspectByte = (GifByteType)(intval & 0xff);
            continue;
            memset(LocalColorKeys, '\0', sizeof(LocalColorKeys));
        }
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "  rgb %d %d %d is %c",
                   &red, &green, &blue, &KeyTable[ColorMapSize]) == 4)
        {
            ColorMapSize++;
        }
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "  rgb %d %d %d", &red, &green, &blue) == 3)
        {
            ColorMap[ColorMapSize].Red = red;
        }
  
        /* GIF inclusion */
-       // cppcheck-suppress invalidscanf 
-       else if (sscanf(buf, "include %s", InclusionFile) == 1)
+       /* ugly magic number is because scanf has no */
+       else if (sscanf(buf, "include %63s", InclusionFile) == 1)
        {
            int         ErrorCode;
            bool        DoTranslation;
            GifPixelType        Translation[256];
  
            GifFileType *Inclusion;
-           SavedImage  *NewImage, *CopyFrom;
+           SavedImage  *CopyFrom;
  
            if ((Inclusion = DGifOpenFileName(InclusionFile, &ErrorCode)) == NULL) {
                PrintGifError(ErrorCode);
                exit(EXIT_FAILURE);
            }
  
+           //cppcheck-suppress nullPointerRedundantCheck
            if ((DoTranslation = (GifFileOut->SColorMap!=(ColorMapObject*)NULL)))
            {
                ColorMapObject  *UnionMap;
  
-               UnionMap = GifUnionColorMap(GifFileOut->SColorMap,
-                                        Inclusion->SColorMap, Translation);
+               //cppcheck-suppress nullPointerRedundantCheck
+               UnionMap = GifUnionColorMap(GifFileOut->SColorMap, Inclusion->SColorMap, Translation);
  
                if (UnionMap == NULL)
                {
                    PARSE_ERROR("Inclusion failed --- global map conflict.");
+                   //cppcheck-suppress nullPointerRedundantCheck
                    PrintGifError(GifFileOut->Error);
                    if (Inclusion != NULL) DGifCloseFile(Inclusion, NULL);
                    if (GifFileOut != NULL) EGifCloseFile(GifFileOut, NULL);
                GifFileOut->SColorMap = UnionMap;
            }
  
+           //cppcheck-suppress nullPointerRedundantCheck
            for (CopyFrom = Inclusion->SavedImages;
+                //cppcheck-suppress nullPointerRedundantCheck
                 CopyFrom < Inclusion->SavedImages + Inclusion->ImageCount;
                 CopyFrom++)
            {
+               SavedImage      *NewImage;
                if ((NewImage = GifMakeSavedImage(GifFileOut, CopyFrom)) == NULL)
                {
                    PARSE_ERROR("Inclusion failed --- out of memory.");
+                   //cppcheck-suppress nullPointerRedundantCheck
                    PrintGifError(GifFileOut->Error);
                    if (Inclusion != NULL) DGifCloseFile(Inclusion, NULL);
                    if (GifFileOut != NULL) EGifCloseFile(GifFileOut, NULL);
  
                    while (isspace(*tp))
                        tp++;
-                   // cppcheck-suppress invalidscanf 
                    if (sscanf(tp, "disposal mode %d\n", &gcb.DisposalMode))
                        continue;
                    if (strcmp(tp, "user input flag on\n") == 0) {
                        gcb.UserInputFlag = false;
                        continue;
                    }
-                   // cppcheck-suppress invalidscanf 
                    if (sscanf(tp, "delay %d\n", &gcb.DelayTime))
                        continue;
-                   // cppcheck-suppress invalidscanf 
                    if (sscanf(tp, "transparent index %d\n",
                               &gcb.TransparentColor))
                        continue;
            }
  
        }
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "netscape loop %u", &intval))
        {
            unsigned char params[3] = {1, 0, 0};
            }
            
        }
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "extension %x", &ExtCode))
        {
            int bc = 0;
        /*
         * Accept image attributes
         */
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "image top %d\n", &NewImage->ImageDesc.Top) == 1)
            continue;
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf, "image left %d\n", &NewImage->ImageDesc.Left)== 1)
            continue;
  
            continue;
        }
  
-       // cppcheck-suppress invalidscanf 
        else if (sscanf(buf,
                        "image bits %d by %d",
                        &NewImage->ImageDesc.Width,
@@@ -693,6 -683,7 +684,7 @@@ static void DumpExtensions(GifFileType 
            putchar('\n');
            while (!last && ep[1].Function == CONTINUE_EXT_FUNC_CODE) {
                ++ep;
+               last = (ep - ExtensionBlocks == (ExtensionBlockCount - 1));
                VisibleDumpBuffer(ep->Bytes, ep->ByteCount);
                putchar('\n');
            }
            putchar('\n');
            while (!last && ep[1].Function == CONTINUE_EXT_FUNC_CODE) {
                ++ep;
+               last = (ep - ExtensionBlocks == (ExtensionBlockCount - 1));
                VisibleDumpBuffer(ep->Bytes, ep->ByteCount);
                putchar('\n');
            }
            printf("\ttransparent index %d\n", gcb.TransparentColor);
            printf("end\n\n");
        }
-       else if (ep->Function == APPLICATION_EXT_FUNC_CODE 
+       else if (!last
+                && ep->Function == APPLICATION_EXT_FUNC_CODE
+                && ep->ByteCount >= 11
+                && (ep+1)->ByteCount >= 3
                 && memcmp(ep->Bytes, "NETSCAPE2.0", 11) == 0) {
            unsigned char *params = (++ep)->Bytes;
            unsigned int loopcount = params[1] | (params[2] << 8);
            VisibleDumpBuffer(ep->Bytes, ep->ByteCount);
            while (!last && ep[1].Function == CONTINUE_EXT_FUNC_CODE) {
                ++ep;
+               last = (ep - ExtensionBlocks == (ExtensionBlockCount - 1));
                VisibleDumpBuffer(ep->Bytes, ep->ByteCount);
                putchar('\n');
            }
@@@ -847,7 -843,7 +844,7 @@@ static void Gif2Icon(char *FileName
        for (i = 0; i < image->ImageDesc.Height; i++) {
            for (j = 0; j < image->ImageDesc.Width; j++) {
                GifByteType ch = image->RasterBits[i*image->ImageDesc.Width + j];
-               if (ColorCount < PRINTABLES)
+               if (ColorCount < PRINTABLES && ch < PRINTABLES)
                    putchar(NameTable[ch]);
                else
                    printf("%02x", ch);
      if (fdin == -1)
        (void) printf("# End of %s dump\n", FileName);
  
+     /*
+      * Sanity checks.
+      */
+     /* check that the background color isn't garbage (SF bug #87) */
+     if (GifFile->SBackGroundColor < 0
+           || GifFile->SBackGroundColor >= GifFile->SColorMap->ColorCount) {
+         fprintf(stderr, "gifbuild: background color invalid for screen colormap.\n");
+     }
      if (DGifCloseFile(GifFile, &ErrorCode) == GIF_ERROR) {
        PrintGifError(ErrorCode);
        exit(EXIT_FAILURE);
diff --combined gifclrmp.c
@@@ -17,9 -17,8 +17,9 @@@ gifclrmap - extract colormaps from GIF 
  
  #define PROGRAM_NAME  "gifclrmp"
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -223,6 -222,8 +223,8 @@@ int main(int argc, char **argv
                /* pass through extension records */
                if (DGifGetExtension(GifFileIn, &ExtCode, &Extension) == GIF_ERROR)
                    QuitGifError(GifFileIn, GifFileOut);
+               if (Extension == NULL)
+                   break;
                if (EGifPutExtensionLeader(GifFileOut, ExtCode) == GIF_ERROR)
                    QuitGifError(GifFileIn, GifFileOut);
                if (EGifPutExtensionBlock(GifFileOut, 
diff --combined gifcolor.c
@@@ -18,9 -18,8 +18,9 @@@ gifcolor - generate color test-pattern 
  #define LINE_LEN              40
  #define IMAGEWIDTH            LINE_LEN*GIF_FONT_WIDTH
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -135,7 -134,6 +135,6 @@@ int main(int argc, char **argv
  static void GenRasterTextLine(GifRowType *RasterBuffer, char *TextLine,
                                        int BufferWidth, int ForeGroundIndex)
  {
-     unsigned char c;
      unsigned char Byte, Mask;
      int i, j, k, CharPosX, Len = strlen(TextLine);
  
          for (j = 0; j < GIF_FONT_HEIGHT; j++) RasterBuffer[j][i] = BackGround;
  
      for (i = CharPosX = 0; i < Len; i++, CharPosX += GIF_FONT_WIDTH) {
-       c = TextLine[i];
+       unsigned char c = TextLine[i];
        for (j = 0; j < GIF_FONT_HEIGHT; j++) {
            Byte = GifAsciiTable8x8[(unsigned short)c][j];
            for (k = 0, Mask = 128; k < GIF_FONT_WIDTH; k++, Mask >>= 1)
diff --combined gifecho.c
+++ b/gifecho.c
@@@ -25,9 -25,8 +25,9 @@@ gifecho - generate a GIF from ASCII tex
  #define DEFAULT_COLOR_GREEN   255
  #define DEFAULT_COLOR_BLUE    255
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -57,7 -56,7 +57,7 @@@ int main(int argc, char **argv
        ForeGroundIndex = DEFAULT_FG_INDEX;
      bool Error, ClrMapSizeFlag = false, ForeGroundFlag = false,
        TextLineFlag = false, HelpFlag = false, ColorFlag = false;
-     char *TextLines[MAX_NUM_TEXT_LINES], Line[LINE_LEN];
+     char *TextLines[MAX_NUM_TEXT_LINES];
      GifRowType RasterBuffer[GIF_FONT_HEIGHT];
      ColorMapObject *ColorMap;
      GifFileType *GifFile;
@@@ -91,6 -90,7 +91,7 @@@
        ImageWidth = GIF_FONT_WIDTH * strlen(TextLines[0]);
      }
      else {
+       char Line[LINE_LEN];
        NumOfLines = l = 0;
        while (fgets(Line, LINE_LEN - 1, stdin)) {
            for (i = strlen(Line); i > 0 && Line[i-1] <= ' '; i--);
      if (EGifCloseFile(GifFile, &ErrorCode) == GIF_ERROR)
      {
        PrintGifError(ErrorCode);
-       if (GifFile != NULL) {
-           EGifCloseFile(GifFile, NULL);
-       }
        exit(EXIT_FAILURE);
      }
  
  static void GenRasterTextLine(GifRowType *RasterBuffer, char *TextLine,
                                        int BufferWidth, int ForeGroundIndex)
  {
-     unsigned char c;
      unsigned char Byte, Mask;
      int i, j, k, CharPosX, Len = strlen(TextLine);
  
          for (j = 0; j < GIF_FONT_HEIGHT; j++) RasterBuffer[j][i] = 0;
  
      for (i = CharPosX = 0; i < Len; i++, CharPosX += GIF_FONT_WIDTH) {
-       c = TextLine[i];
+       unsigned char c = TextLine[i];
        for (j = 0; j < GIF_FONT_HEIGHT; j++) {
            Byte = GifAsciiTable8x8[(unsigned short)c][j];
            for (k = 0, Mask = 128; k < GIF_FONT_WIDTH; k++, Mask >>= 1)
diff --combined giffix.c
+++ b/giffix.c
@@@ -15,9 -15,8 +15,9 @@@ giffix - attempt to fix a truncated GI
  
  #define PROGRAM_NAME  "giffix"
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -202,7 -201,7 +202,7 @@@ int main(int argc, char **argv
  ******************************************************************************/
  static void QuitGifError(GifFileType *GifFileIn, GifFileType *GifFileOut)
  {
-     fprintf(stderr, "\nFollowing unrecoverable error occured:");
+     fprintf(stderr, "\nFollowing unrecoverable error occurred:");
      if (GifFileIn != NULL) {
        PrintGifError(GifFileIn->Error);
        EGifCloseFile(GifFileIn, NULL);
diff --combined gifhisto.c
@@@ -19,9 -19,8 +19,9 @@@ gifhisto - make a color histogram from 
  #define DEFAULT_HISTO_HEIGHT  256
  #define HISTO_BITS_PER_PIXEL  2       /* Size of bitmap for histogram GIF. */
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
diff --combined gifinto.c
+++ b/gifinto.c
@@@ -4,7 -4,6 +4,6 @@@ gifinto - save GIF on stdin to file if 
  
  *****************************************************************************/
  
- #include <unistd.h>
  #include <fcntl.h>
  #include <stdio.h>
  #include <stdlib.h>
@@@ -14,6 -13,8 +13,8 @@@
  
  #ifdef _WIN32
  #include <io.h>
+ #else
+ #include <unistd.h>
  #endif /* _WIN32 */
  
  #include "gif_lib.h"
@@@ -27,9 -28,8 +28,9 @@@
  #define       DEFAULT_OUT_NAME        "GifInto.Gif"
  #define DEFAULT_TMP_NAME      "TempInto.XXXXXX"
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -74,7 -74,7 +75,7 @@@ int main(int argc, char **argv
      int FD;
      int       NumFiles;
      bool Error, MinSizeFlag = false, HelpFlag = false;
-     char **FileName = NULL, FoutTmpName[STRLEN], FullPath[STRLEN], *p;
+     char **FileName = NULL, FoutTmpName[STRLEN+1], FullPath[STRLEN+1], *p;
      FILE *Fin, *Fout;
  
      if ((Error = GAGetArgs(argc, argv, CtrlStr, &GifNoisyPrint,
      if ( *FileName == NULL ) GIF_EXIT("No valid Filename given.");
      if ( strlen(*FileName) > STRLEN-1 ) GIF_EXIT("Filename too long.");
      memset(FullPath, '\0', sizeof(FullPath));
-     // cppcheck-suppress redundantCopy
      strncpy(FullPath, *FileName, STRLEN);
      if ((p = strrchr(FullPath, '/')) != NULL ||
        (p = strrchr(FullPath, '\\')) != NULL)
        fclose(Fout);
        unlink(*FileName);
        if (rename(FoutTmpName, *FileName) != 0) {
-           char DefaultName[STRLEN];
+           char DefaultName[STRLEN+1];
+           memset(DefaultName, '\0', sizeof(DefaultName));
            if ( (strlen(FullPath) + strlen(DEFAULT_OUT_NAME)) > STRLEN-1 ) GIF_EXIT("Filename too long.");
            strncpy(DefaultName, FullPath, STRLEN);
-           // cppcheck-suppress uninitstring
            strcat(DefaultName, DEFAULT_OUT_NAME);
            if (rename(FoutTmpName, DefaultName) == 0) {
                char s[STRLEN];
diff --combined giftext.c
+++ b/giftext.c
@@@ -21,9 -21,8 +21,9 @@@ giftext - dump GIF pixels and metadata 
  
  #define MAKE_PRINTABLE(c)  (isprint(c) ? (c) : ' ')
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "
@@@ -315,11 -314,11 +315,11 @@@ static void PrintCodeBlock(GifFileType 
  {
      static int CrntPlace = 0; 
      static long CodeCount = 0;
-     int i, Percent, Len;
-     long NumBytes;
+     int i, Len;
  
      if (Reset || CodeBlock == NULL) {
        if (CodeBlock == NULL) {
+           long NumBytes = 0;
            if (CrntPlace > 0) {
                printf("\n");
                CodeCount += CrntPlace - 16;
            if (GifFile->Image.ColorMap)
                NumBytes = ((((long) GifFile->Image.Width) * GifFile->Image.Height)
                                * GifFile->Image.ColorMap->BitsPerPixel) / 8;
-           else
+           else if (GifFile->SColorMap != NULL)
                NumBytes = ((((long) GifFile->Image.Width) * GifFile->Image.Height)
                                * GifFile->SColorMap->BitsPerPixel) / 8;
-           Percent = 100 * CodeCount / NumBytes;
-           printf("\nCompression ratio: %ld/%ld (%d%%).\n",
+           /* FIXME: What should the compression ratio be if no color table? */
+           if (NumBytes > 0) {
+               int Percent = 100 * CodeCount / NumBytes;
+               printf("\nCompression ratio: %ld/%ld (%d%%).\n",
                        CodeCount, NumBytes, Percent);
+           }
            return;
        }
        CrntPlace = 0;
diff --combined gifwedge.c
@@@ -20,9 -20,8 +20,9 @@@ gifwedge - create a GIF test patter
  
  #define DEFAULT_NUM_LEVELS    16     /* Number of colors to gen the image. */
  
 +__attribute__((__section__(".tizen.build-id")))
  static char
 -    *VersionStr =
 +    VersionStr[] =
        PROGRAM_NAME
        VERSION_COOKIE
        "       Gershon Elber,  "