From: Harlan Stenn Date: Mon, 23 Nov 2015 10:55:16 +0000 (+0000) Subject: ChangeLog, caljulian.c: X-Git-Tag: NTP_4_3_82~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a68c2fda507c0a6c8f899b40a52f62671fe49f4b;p=thirdparty%2Fntp.git ChangeLog, caljulian.c: * CID 1339955: Free allocated memory in caljulian test. HStenn. * CID 1339962: Explicitly initialize variable in caljulian test. HStenn. bk: 5652f094XJpA7DubZuJ-wqt9efi_HA --- diff --git a/ChangeLog b/ChangeLog index 41d4d248f..254284f0d 100644 --- 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 diff --git a/tests/libntp/caljulian.c b/tests/libntp/caljulian.c index 30ceaaec0..b25f8acac 100644 --- a/tests/libntp/caljulian.c +++ b/tests/libntp/caljulian.c @@ -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; } }