comparison Isolated/tErrorLib.c @ 39:c07dbd386ded

fixed memory leak in tErrorLib
author Eric Wing <ewing@anscamobile.com>
date Mon, 23 May 2011 11:33:58 -0700
parents 71b465ff0622
children 72570fcd30e8
comparison
equal deleted inserted replaced
38:71b465ff0622 39:c07dbd386ded
923 * If memory allocation must be minimized, I recommend just 923 * If memory allocation must be minimized, I recommend just
924 * using the error number interface by itself which 924 * using the error number interface by itself which
925 * will always keep the strings at NULL, and don't mess 925 * will always keep the strings at NULL, and don't mess
926 * with the asprintf/sprintf code. 926 * with the asprintf/sprintf code.
927 */ 927 */
928 if(NULL != error_message->errorString)
929 {
930 /* Need to free errorString from previous pass otherwise we leak.
931 * Maybe there is a smarter way to avoid the free/malloc,
932 * but this would probably require determining the length of the
933 * final string beforehand which probably implies two
934 * *printf calls which may or may not be better.
935 */
936 free(error_message->errorString);
937 error_message->errorString = NULL;
938 }
928 939
929 ret_num_chars = vasprintf(&error_message->errorString, err_str, argp); 940 ret_num_chars = vasprintf(&error_message->errorString, err_str, argp);
930 /* vasprintf returns -1 as an error */ 941 /* vasprintf returns -1 as an error */
931 if(-1 == ret_num_chars) 942 if(-1 == ret_num_chars)
932 { 943 {