From a0ccc0f0faf4c12c0ef81777f6d9ae5e1a1107f9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 3 Jul 2013 09:34:12 -0500 Subject: [svn-r23860] HDFFV-8322: reduce valgrind memory leaks for ex_image2 Tested:" local linux --- hl/examples/ex_image2.c | 8 ++++++++ hl/src/H5LT.c | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hl/examples/ex_image2.c b/hl/examples/ex_image2.c index 77398c4..76c3a75 100644 --- a/hl/examples/ex_image2.c +++ b/hl/examples/ex_image2.c @@ -46,6 +46,10 @@ int main( void ) /* make the image */ status=H5IMmake_image_8bit( file_id, IMAGE1_NAME, width, height, gbuf ); + if (gbuf) { + free(gbuf); + gbuf = NULL; + } /*------------------------------------------------------------------------- * define a palette, blue to red tones @@ -75,6 +79,10 @@ int main( void ) /* make dataset */ status=H5IMmake_image_24bit( file_id, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", gbuf ); + if (gbuf) { + free(gbuf); + gbuf = NULL; + } /* close the file. */ H5Fclose( file_id ); diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 88f8de4..b2c8949 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -2175,8 +2175,10 @@ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) input_len = HDstrlen(text); myinput = HDstrdup(text); - if((type_id = H5LTyyparse()) < 0) + if((type_id = H5LTyyparse()) < 0) { + HDfree(myinput); goto out; + } HDfree(myinput); input_len = 0; -- cgit v0.12