INN commit: trunk/tests (4 files)

INN Commit rra at isc.org
Sun Apr 3 13:26:46 UTC 2016


    Date: Sunday, April 3, 2016 @ 06:26:46
  Author: iulius
Revision: 9997

Missing fclose() and mishandling of *artnum

Modified:
  trunk/tests/lib/hashtab-t.c
  trunk/tests/lib/tst-t.c
  trunk/tests/overview/api-t.c
  trunk/tests/overview/overview-t.c

-----------------------+
 lib/hashtab-t.c       |    5 ++++-
 lib/tst-t.c           |    5 ++++-
 overview/api-t.c      |   10 ++++++++--
 overview/overview-t.c |   10 ++++++++--
 4 files changed, 24 insertions(+), 6 deletions(-)

Modified: lib/hashtab-t.c
===================================================================
--- lib/hashtab-t.c	2016-04-03 13:23:45 UTC (rev 9996)
+++ lib/hashtab-t.c	2016-04-03 13:26:46 UTC (rev 9997)
@@ -165,8 +165,10 @@
     }
     ok(37, !reported);
 
-    if (fseek(words, 0, SEEK_SET) < 0)
+    if (fseek(words, 0, SEEK_SET) < 0) {
+        fclose(words);
         sysdie("Unable to rewind words file");
+    }
     reported = false;
     if (hash == NULL)
         reported = true;
@@ -182,6 +184,7 @@
     ok(38, !reported);
 
     hash_free(hash);
+    fclose(words);
 
     return 0;
 }

Modified: lib/tst-t.c
===================================================================
--- lib/tst-t.c	2016-04-03 13:23:45 UTC (rev 9996)
+++ lib/tst-t.c	2016-04-03 13:26:46 UTC (rev 9997)
@@ -102,8 +102,10 @@
     }
     ok(37, !reported);
 
-    if (fseek(words, 0, SEEK_SET) < 0)
+    if (fseek(words, 0, SEEK_SET) < 0) {
+        fclose(words);
         sysdie("Unable to rewind words file");
+    }
     reported = false;
     if (tst == NULL)
         reported = true;
@@ -130,6 +132,7 @@
         }
     }
     tst_cleanup(tst);
+    fclose(words);
     ok(38, !reported);
 
     return 0;

Modified: overview/api-t.c
===================================================================
--- overview/api-t.c	2016-04-03 13:23:45 UTC (rev 9996)
+++ overview/api-t.c	2016-04-03 13:26:46 UTC (rev 9997)
@@ -140,7 +140,7 @@
     *start = '\0';
     start++;
     *artnum = strtoul(start, NULL, 10);
-    if (artnum == 0)
+    if (*artnum == 0)
         die("Cannot parse article number in input data");
     return start;
 }
@@ -393,8 +393,10 @@
     if (overdata == NULL)
         sysdie("Cannot open %s for reading", data);
     expected = vector_new();
-    if (fgets(buffer, sizeof(buffer), overdata) == NULL)
+    if (fgets(buffer, sizeof(buffer), overdata) == NULL) {
+        fclose(overdata);
         die("Unexpected end of file in %s", data);
+    }
     overview_data_parse(buffer, &artnum);
     group = xstrdup(buffer);
     while (fgets(buffer, sizeof(buffer), overdata) != NULL) {
@@ -412,6 +414,7 @@
         warn("Unable to open search for %s:%lu", buffer, start);
         free(group);
         vector_free(expected);
+        fclose(overdata);
         return false;
     }
     i = 0;
@@ -432,6 +435,7 @@
     }
     free(group);
     vector_free(expected);
+    fclose(overdata);
     return status;
 }
 
@@ -470,6 +474,7 @@
         warn("Unable to open full search for %s", group);
         free(group);
         vector_free(expected);
+        fclose(overdata);
         return false;
     }
     i = 0;
@@ -490,6 +495,7 @@
     }
     free(group);
     vector_free(expected);
+    fclose(overdata);
     return status;
 }
 

Modified: overview/overview-t.c
===================================================================
--- overview/overview-t.c	2016-04-03 13:23:45 UTC (rev 9996)
+++ overview/overview-t.c	2016-04-03 13:26:46 UTC (rev 9997)
@@ -151,7 +151,7 @@
     *start = '\0';
     start++;
     *artnum = strtoul(start, NULL, 10);
-    if (artnum == 0)
+    if (*artnum == 0)
         die("Cannot parse article number in input data");
     return start;
 }
@@ -377,8 +377,10 @@
     if (overview == NULL)
         sysdie("Cannot open %s for reading", data);
     expected = vector_new();
-    if (fgets(buffer, sizeof(buffer), overview) == NULL)
+    if (fgets(buffer, sizeof(buffer), overview) == NULL) {
+        fclose(overview);
         die("Unexpected end of file in %s", data);
+    }
     overview_data_parse(buffer, &artnum);
     group = xstrdup(buffer);
     while (fgets(buffer, sizeof(buffer), overview) != NULL) {
@@ -396,6 +398,7 @@
         warn("Unable to open search for %s:%lu", buffer, start);
         free(group);
         vector_free(expected);
+        fclose(overview);
         return false;
     }
     i = 0;
@@ -421,6 +424,7 @@
     }
     free(group);
     vector_free(expected);
+    fclose(overview);
     return status;
 }
 
@@ -461,6 +465,7 @@
         warn("Unable to open full search for %s", group);
         free(group);
         vector_free(expected);
+        fclose(overview);
         return false;
     }
     i = 0;
@@ -486,6 +491,7 @@
     }
     free(group);
     vector_free(expected);
+    fclose(overview);
     return status;
 }
 



More information about the inn-committers mailing list