]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog, caljulian.c:
authorHarlan Stenn <stenn@ntp.org>
Mon, 23 Nov 2015 10:55:16 +0000 (10:55 +0000)
committerHarlan Stenn <stenn@ntp.org>
Mon, 23 Nov 2015 10:55:16 +0000 (10:55 +0000)
  * CID 1339955: Free allocated memory in caljulian test.  HStenn.
  * CID 1339962: Explicitly initialize variable in caljulian test.  HStenn.

bk: 5652f094XJpA7DubZuJ-wqt9efi_HA

ChangeLog
tests/libntp/caljulian.c

index 41d4d248f296195e6e04cb2c57ddf26c1889f9ad..254284f0ddc3e630cdecc11c397934386dfef03f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 ---
 
 * [Sec 2956] small-step/big-step.  Close the panic gate earlier.  HStenn.
+* CID 1339955: Free allocated memory in caljulian test.  HStenn.
+* CID 1339962: Explicitly initialize variable in caljulian test.  HStenn.
 * [Bug 2932] Update leapsecond file info in miscopt.html.  CWoodbury, HStenn.
 * [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in.  HMurray
 * [Bug 2954] Version 4.2.8p4 crashes on startup with sig fault
index 30ceaaec0605d56df10b63dfbb3c46d3d828e904..b25f8acac8e7f0e84ed93512ac9a1418f2fe4038 100644 (file)
@@ -23,8 +23,9 @@ char *
 CalendarToString(const struct calendar cal)
 {
        char * str = emalloc (sizeof (char) * 100);
-
        char buffer[100] ="";
+
+       *str = '\0';
        snprintf(buffer, 100, "%u", cal.year);
        strcat(str, buffer);
        strcat(str, "-");
@@ -51,17 +52,22 @@ CalendarToString(const struct calendar cal)
 int // technically boolean
 IsEqual(const struct calendar expected, const struct calendar actual)
 {
-       if (expected.year == actual.year &&
-               (expected.yearday == actual.yearday ||
-                (expected.month == actual.month &&
-                 expected.monthday == actual.monthday)) &&
-               expected.hour == actual.hour &&
-               expected.minute == actual.minute &&
-               expected.second == actual.second) {
+       if (   expected.year == actual.year
+           && (   expected.yearday == actual.yearday
+               || (   expected.month == actual.month
+                   && expected.monthday == actual.monthday))
+           && expected.hour == actual.hour
+           && expected.minute == actual.minute
+           && expected.second == actual.second) {
                return TRUE;
        } else {
-               printf("expected: %s but was %s", CalendarToString(expected),
-                       CalendarToString(actual));
+               char *p_exp, *p_act;
+
+               p_exp = CalendarToString(expected);
+               p_act = CalendarToString(actual);
+               printf("expected: %s but was %s", p_exp, p_act);
+               free(p_exp);
+               free(p_act);
                return FALSE;
        }
 }