# HG changeset patch # User Eric Wing # Date 1306175638 25200 # Node ID c07dbd386ded62c8c832585c2c1d2e74eb44c34c # Parent 71b465ff062254871d194b0a268c8786a36404f3 fixed memory leak in tErrorLib diff -r 71b465ff0622 -r c07dbd386ded Isolated/tErrorLib.c --- a/Isolated/tErrorLib.c Thu Apr 28 16:22:30 2011 -0700 +++ b/Isolated/tErrorLib.c Mon May 23 11:33:58 2011 -0700 @@ -925,6 +925,17 @@ * will always keep the strings at NULL, and don't mess * with the asprintf/sprintf code. */ + if(NULL != error_message->errorString) + { + /* Need to free errorString from previous pass otherwise we leak. + * Maybe there is a smarter way to avoid the free/malloc, + * but this would probably require determining the length of the + * final string beforehand which probably implies two + * *printf calls which may or may not be better. + */ + free(error_message->errorString); + error_message->errorString = NULL; + } ret_num_chars = vasprintf(&error_message->errorString, err_str, argp); /* vasprintf returns -1 as an error */