home *** CD-ROM | disk | FTP | other *** search
- From decwrl!shlump.nac.dec.com!decuac!haven!aplcen!uunet!allbery Wed May 30 08:56:18 PDT 1990
- Article 1608 of comp.sources.misc:
- Path: decwrl!shlump.nac.dec.com!decuac!haven!aplcen!uunet!allbery
- From: mark%zok@sj.ate.slb.com (Mark W. Snitily)
- Newsgroups: comp.sources.misc
- Subject: v13i017: patch to v10i079: ppmtoxpm
- Message-ID: <91061@uunet.UU.NET>
- Date: 30 May 90 00:37:31 GMT
- Sender: allbery@uunet.UU.NET
- Lines: 83
- Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 13, Issue 17
- Submitted-by: mark%zok@sj.ate.slb.com (Mark W. Snitily)
- Archive-name: ppmtoxpm.p1
-
- Brandon,
-
- The following is a patch which corrects a malloc argument bug in ppmtoxpm
- (v10i079). Classic case of when an "i" should have been a "j".
-
- -- Mark
-
- Mark W. Snitily Consulting Services:
- 894 Brookgrove Lane Graphics, Operating Systems, Compilers
- Cupertino, CA 95014 (408) 252-0456
- mark@zok.uucp
-
- *** ppmtoxpm.c.org Wed Feb 14 16:42:43 1990
- --- ppmtoxpm.c Tue May 29 00:14:16 1990
- ***************
- *** 13,18 ****
- --- 13,20 ----
- ** with their permission is being made available to the public with the above
- ** copyright notice and permission notice.
- **
- + ** 28-May-90 MWS Corrected malloc argument bug in routine gen_cmap().
- + **
- */
-
- #include <stdio.h>
- ***************
- *** 285,291 ****
-
- /* Allocate memory for printed number. Abort if error. */
- if (!(str = (char *) malloc(digits+1)))
- ! pm_error("out of memory", 0, 0, 0, 0, 0);
-
- /* Generate characters starting with least significant digit. */
- p = str + digits;
- --- 287,293 ----
-
- /* Allocate memory for printed number. Abort if error. */
- if (!(str = (char *) malloc(digits+1)))
- ! pm_error("out of memory allocating number string", 0, 0, 0, 0, 0);
-
- /* Generate characters starting with least significant digit. */
- p = str + digits;
- ***************
- *** 382,389 ****
- if (r == rgbn[j].r && g == rgbn[j].g && b == rgbn[j].b) {
-
- /* Matched. Allocate string, copy mnemonic, and exit. */
- ! if (!(str = (char *) malloc(strlen(rgbn[i].name)+1)))
- ! pm_error("out of memory", 0, 0, 0, 0, 0);
- strcpy(str, rgbn[j].name);
- cmap[i].rgbname = str;
- matched = 1;
- --- 384,392 ----
- if (r == rgbn[j].r && g == rgbn[j].g && b == rgbn[j].b) {
-
- /* Matched. Allocate string, copy mnemonic, and exit. */
- ! if (!(str = (char *) malloc(strlen(rgbn[j].name)+1)))
- ! pm_error("out of memory allocating color mnemonic",
- ! 0, 0, 0, 0, 0);
- strcpy(str, rgbn[j].name);
- cmap[i].rgbname = str;
- matched = 1;
- ***************
- *** 398,404 ****
- mval == 0x00FF ? 8 :
- mval == 0x0FFF ? 11 :
- 14)))
- ! pm_error("out of memory", 0, 0, 0, 0, 0);
-
- sprintf(str, mval == 0x000F ? "#%X%X%X" :
- mval == 0x00FF ? "#%02X%02X%02X" :
- --- 401,407 ----
- mval == 0x00FF ? 8 :
- mval == 0x0FFF ? 11 :
- 14)))
- ! pm_error("out of memory allocating absolute RGB", 0, 0, 0, 0, 0);
-
- sprintf(str, mval == 0x000F ? "#%X%X%X" :
- mval == 0x00FF ? "#%02X%02X%02X" :
-
-
-