From e73609bf2f5770aaea795f369c67ee8dab6457a1 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 1 Mar 2014 20:40:48 +0000 Subject: Fix memory leak when row validation fails, and user is catching exceptions git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2144 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libppm1.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'lib/libppm1.c') diff --git a/lib/libppm1.c b/lib/libppm1.c index f1eb8b7d..0658529a 100644 --- a/lib/libppm1.c +++ b/lib/libppm1.c @@ -252,22 +252,26 @@ validateRppmRow(pixel * const pixelrow, pixval const b = PPM_GETB(pixelrow[col]); if (r > maxval) - pm_error("Red sample value %u is greater than maxval (%u)", - r, maxval); + pm_asprintf( + errorP, + "Red sample value %u is greater than maxval (%u)", + r, maxval); if (g > maxval) - pm_error("Green sample value %u is greater than maxval (%u)", - g, maxval); + pm_asprintf( + errorP, + "Green sample value %u is greater than maxval (%u)", + g, maxval); if (b > maxval) - pm_error("Blue sample value %u is greater than maxval (%u)", - b, maxval); + pm_asprintf( + errorP, + "Blue sample value %u is greater than maxval (%u)", + b, maxval); } } } - - static void readRppmRow(FILE * const fileP, pixel * const pixelrow, -- cgit 1.4.1