home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume13 / ppmtoxpm.p1
Encoding:
Internet Message Format  |  1991-08-27  |  3.5 KB

  1. From decwrl!shlump.nac.dec.com!decuac!haven!aplcen!uunet!allbery Wed May 30 08:56:18 PDT 1990
  2. Article 1608 of comp.sources.misc:
  3. Path: decwrl!shlump.nac.dec.com!decuac!haven!aplcen!uunet!allbery
  4. From: mark%zok@sj.ate.slb.com (Mark W. Snitily)
  5. Newsgroups: comp.sources.misc
  6. Subject: v13i017: patch to v10i079: ppmtoxpm
  7. Message-ID: <91061@uunet.UU.NET>
  8. Date: 30 May 90 00:37:31 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Lines: 83
  11. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  12.  
  13. Posting-number: Volume 13, Issue 17
  14. Submitted-by: mark%zok@sj.ate.slb.com (Mark W. Snitily)
  15. Archive-name: ppmtoxpm.p1
  16.  
  17. Brandon,
  18.  
  19. The following is a patch which corrects a malloc argument bug in ppmtoxpm
  20. (v10i079).  Classic case of when an "i" should have been a "j".
  21.  
  22. -- Mark
  23.  
  24. Mark W. Snitily                 Consulting Services:
  25. 894 Brookgrove Lane             Graphics, Operating Systems, Compilers
  26. Cupertino, CA 95014             (408) 252-0456
  27. mark@zok.uucp
  28.  
  29. *** ppmtoxpm.c.org    Wed Feb 14 16:42:43 1990
  30. --- ppmtoxpm.c    Tue May 29 00:14:16 1990
  31. ***************
  32. *** 13,18 ****
  33. --- 13,20 ----
  34.   ** with their permission is being made available to the public with the above
  35.   ** copyright notice and permission notice.
  36.   **
  37. + ** 28-May-90  MWS  Corrected malloc argument bug in routine gen_cmap().
  38. + **
  39.   */
  40.   
  41.   #include <stdio.h>
  42. ***************
  43. *** 285,291 ****
  44.   
  45.      /* Allocate memory for printed number.  Abort if error. */
  46.      if (!(str = (char *) malloc(digits+1)))
  47. !       pm_error("out of memory", 0, 0, 0, 0, 0);
  48.   
  49.      /* Generate characters starting with least significant digit. */
  50.      p = str + digits;
  51. --- 287,293 ----
  52.   
  53.      /* Allocate memory for printed number.  Abort if error. */
  54.      if (!(str = (char *) malloc(digits+1)))
  55. !       pm_error("out of memory allocating number string", 0, 0, 0, 0, 0);
  56.   
  57.      /* Generate characters starting with least significant digit. */
  58.      p = str + digits;
  59. ***************
  60. *** 382,389 ****
  61.                if (r == rgbn[j].r && g == rgbn[j].g && b == rgbn[j].b) {
  62.   
  63.                   /* Matched.  Allocate string, copy mnemonic, and exit. */
  64. !                 if (!(str = (char *) malloc(strlen(rgbn[i].name)+1)))
  65. !                    pm_error("out of memory", 0, 0, 0, 0, 0);
  66.                   strcpy(str, rgbn[j].name);
  67.                   cmap[i].rgbname = str;
  68.                   matched = 1;
  69. --- 384,392 ----
  70.                if (r == rgbn[j].r && g == rgbn[j].g && b == rgbn[j].b) {
  71.   
  72.                   /* Matched.  Allocate string, copy mnemonic, and exit. */
  73. !                 if (!(str = (char *) malloc(strlen(rgbn[j].name)+1)))
  74. !                    pm_error("out of memory allocating color mnemonic",
  75. !                             0, 0, 0, 0, 0);
  76.                   strcpy(str, rgbn[j].name);
  77.                   cmap[i].rgbname = str;
  78.                   matched = 1;
  79. ***************
  80. *** 398,404 ****
  81.                                     mval == 0x00FF ?  8 :
  82.                                     mval == 0x0FFF ? 11 :
  83.                                                      14)))
  84. !          pm_error("out of memory", 0, 0, 0, 0, 0);
  85.   
  86.         sprintf(str, mval == 0x000F ? "#%X%X%X"       :
  87.                      mval == 0x00FF ? "#%02X%02X%02X" :
  88. --- 401,407 ----
  89.                                     mval == 0x00FF ?  8 :
  90.                                     mval == 0x0FFF ? 11 :
  91.                                                      14)))
  92. !          pm_error("out of memory allocating absolute RGB", 0, 0, 0, 0, 0);
  93.   
  94.         sprintf(str, mval == 0x000F ? "#%X%X%X"       :
  95.                      mval == 0x00FF ? "#%02X%02X%02X" :
  96.  
  97.  
  98.