diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-08-09 03:06:48 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-08-09 03:06:48 +0000 |
commit | e6e30e94b1da12d0a3247db3b25311bafb8230e6 (patch) | |
tree | 546d163508fa3e3b4fa577e85c424357c2027c42 /converter/other | |
parent | e281482f7522e2ccf8f4fad6f194f7ef7d77ef10 (diff) | |
download | netpbm-mirror-e6e30e94b1da12d0a3247db3b25311bafb8230e6.tar.gz netpbm-mirror-e6e30e94b1da12d0a3247db3b25311bafb8230e6.tar.xz netpbm-mirror-e6e30e94b1da12d0a3247db3b25311bafb8230e6.zip |
Remove RLE_CHECK_ALLOC and rle_alloc_error from URT library. This fixes a wild pointer dereference as well as cleans up code
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3656 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
-rw-r--r-- | converter/other/pnmtorle.c | 6 | ||||
-rw-r--r-- | converter/other/rletopnm.c | 24 |
2 files changed, 20 insertions, 10 deletions
diff --git a/converter/other/pnmtorle.c b/converter/other/pnmtorle.c index 67838297..1882fe5d 100644 --- a/converter/other/pnmtorle.c +++ b/converter/other/pnmtorle.c @@ -133,12 +133,14 @@ write_rle_data(void) { MALLOCARRAY(xelrow, width); MALLOCARRAY(scanlines, height); - RLE_CHECK_ALLOC(hdr.cmd, scanlines, "scanline pointers"); + if (!scanlines) + pm_error("Failed to allocate memory for %u scanline pointers", height); for (scan = 0; scan < height; ++scan) { int rc; rc = rle_row_alloc(&hdr, &scanlines[scan]); - RLE_CHECK_ALLOC(hdr.cmd, rc >= 0, "pixel memory"); + if (rc < 0) + pm_error("Failed to allocate memory for a scanline"); } /* Loop through the pnm files image window, read data and flip vertically. */ diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c index 73ab2659..97f271dc 100644 --- a/converter/other/rletopnm.c +++ b/converter/other/rletopnm.c @@ -274,11 +274,15 @@ writePpmRaster(FILE * const imageoutFileP, alpharow = pgm_allocrow(width); MALLOCARRAY(scanlines, height); - RLE_CHECK_ALLOC( hdr.cmd, scanlines, "scanline pointers" ); + if (!scanlines) + pm_error("Failed to allocate memory for %u scanline pointers", height); - for ( scan = 0; scan < height; scan++ ) - RLE_CHECK_ALLOC( hdr.cmd, (rle_row_alloc(&hdr, &scanlines[scan]) >= 0), - "pixel memory" ); + for (scan = 0; scan < height; ++scan) { + int rc; + rc = rle_row_alloc(&hdr, &scanlines[scan]); + if (rc < 0) + pm_error("Failed to allocate memory for a scanline"); + } /* * Loop through those scan lines. */ @@ -375,11 +379,15 @@ writePgmRaster(FILE * const imageoutFileP, alpharow = pgm_allocrow(width); MALLOCARRAY(scanlines, height); - RLE_CHECK_ALLOC( hdr.cmd, scanlines, "scanline pointers" ); + if (!scanlines) + pm_error("Failed to allocate memory for %u scanline pointers", height); - for (scan = 0; scan < height; ++scan) - RLE_CHECK_ALLOC(hdr.cmd, (rle_row_alloc(&hdr, &scanlines[scan]) >= 0), - "pixel memory" ); + for (scan = 0; scan < height; ++scan) { + int rc; + rc = rle_row_alloc(&hdr, &scanlines[scan]); + if (rc < 0) + pm_error("Failed to allocate memory for a scanline"); + } /* * Loop through those scan lines. */ |