# HG changeset patch # User Edgar Simo # Date 1249403644 0 # Node ID be037e51f0800932dfd54ec17ad2473905dbb804 # Parent f0b89cf4bffcf2ddf4f9015d6463c3e3649a368f Allocate memory for testsuite/testcase name so pointer doesn't get bashed. diff -r f0b89cf4bffc -r be037e51f080 test/automated/SDL_at.c --- a/test/automated/SDL_at.c Tue Aug 04 16:26:43 2009 +0000 +++ b/test/automated/SDL_at.c Tue Aug 04 16:34:04 2009 +0000 @@ -9,15 +9,17 @@ #include "SDL_at.h" -#include -#include +#include /* printf/fprintf */ +#include /* va_list */ +#include /* strdup */ +#include /* free */ /* * Internal usage SDL_AT variables. */ -static const char *at_suite_msg = NULL; /**< Testsuite message. */ -static const char *at_test_msg = NULL; /**< Testcase message. */ +static char *at_suite_msg = NULL; /**< Testsuite message. */ +static char *at_test_msg = NULL; /**< Testcase message. */ static int at_success = 0; /**< Number of successful testcases. */ static int at_failure = 0; /**< Number of failed testcases. */ @@ -34,10 +36,14 @@ */ static void SDL_ATcleanup (void) { - at_suite_msg = NULL; - at_test_msg = NULL; - at_success = 0; - at_failure = 0; + if (at_suite_msg != NULL) + free(at_suite_msg); + at_suite_msg = NULL; + if (at_test_msg != NULL) + free(at_test_msg); + at_test_msg = NULL; + at_success = 0; + at_failure = 0; } @@ -56,10 +62,10 @@ SDL_ATprintErr( "AT testsuite does not have a name.\n"); } SDL_ATcleanup(); - at_suite_msg = suite; + at_suite_msg = strdup(suite); /* Verbose message. */ - SDL_ATprintVerbose( 2, "--+---> Started Test Suite '%s'\n", suite ); + SDL_ATprintVerbose( 2, "--+---> Started Test Suite '%s'\n", at_suite_msg ); } @@ -152,7 +158,7 @@ if (testcase == NULL) { SDL_ATprintErr( "AT testcase does not have a name.\n"); } - at_test_msg = testcase; + at_test_msg = strdup(testcase); /* Verbose message. */ SDL_ATprintVerbose( 2, " +---> StartedTest Case '%s'\n", testcase ); @@ -180,6 +186,8 @@ SDL_ATprintVerbose( 2, " +---- Finished Test Case '%s'\n", at_test_msg ); /* Clean up. */ + if (at_test_msg != NULL) + free(at_test_msg); at_test_msg = NULL; }