]> granicus.if.org Git - libexpat/commitdiff
runtests.c: Address cppcheck warning (fixes #283)
authorSebastian Pipping <sebastian@pipping.org>
Wed, 17 Jul 2019 16:05:17 +0000 (18:05 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Wed, 17 Jul 2019 16:05:17 +0000 (18:05 +0200)
[tests/runtests.c:647]: (error) Address of local auto-variable assigned to a function parameter.

expat/tests/runtests.c

index 5c2114eda7639e95c451513e6628ee30254874c4..c0021a79b004a10f8ab15b476f8165306e51f763 100644 (file)
@@ -641,16 +641,18 @@ _run_ext_character_check(const char *text,
                          const XML_Char *expected,
                          const char *file, int line)
 {
-    CharData storage;
+    CharData * const storage = (CharData *)malloc(sizeof(CharData));
 
-    CharData_Init(&storage);
-    test_data->storage = &storage;
+    CharData_Init(storage);
+    test_data->storage = storage;
     XML_SetUserData(parser, test_data);
     XML_SetCharacterDataHandler(parser, ext_accumulate_characters);
     if (_XML_Parse_SINGLE_BYTES(parser, text, (int)strlen(text),
                                 XML_TRUE) == XML_STATUS_ERROR)
         _xml_failure(parser, file, line);
-    CharData_CheckXMLChars(&storage, expected);
+    CharData_CheckXMLChars(storage, expected);
+
+    free(storage);
 }
 
 #define run_ext_character_check(text, test_data, expected)               \