]> granicus.if.org Git - libexpat/commitdiff
minicheck.c: Protect against potential NULL dereference
authorSebastian Pipping <sebastian@pipping.org>
Sat, 15 Jul 2017 17:09:30 +0000 (19:09 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 15 Jul 2017 17:14:49 +0000 (19:14 +0200)
expat/tests/minicheck.c

index 36d9ae3f7cda72e9b6f2a58f00bb5f7267031901..a6cae231b75ee247c33d64f98bcab74fa6c82788 100644 (file)
@@ -73,6 +73,10 @@ tcase_add_test(TCase *tc, tcase_test_function test)
 static void
 tcase_free(TCase *tc)
 {
+    if (! tc) {
+        return;
+    }
+
     free(tc->tests);
     free(tc);
 }
@@ -80,6 +84,10 @@ tcase_free(TCase *tc)
 static void
 suite_free(Suite *suite)
 {
+    if (! suite) {
+        return;
+    }
+
     while (suite->tests != NULL) {
         TCase *next = suite->tests->next_tcase;
         tcase_free(suite->tests);
@@ -193,6 +201,10 @@ srunner_ntests_failed(SRunner *runner)
 void
 srunner_free(SRunner *runner)
 {
+    if (! runner) {
+        return;
+    }
+
     suite_free(runner->suite);
     free(runner);
 }