Skip to content
Myr

Fix leak on error in strptime

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nicolas Williams · parent bdaddcf · Browse files · 2 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−1 removed

  • tests:+1 added−0 removed
  • other:+4 added−1 removed

2 files+5 added−1 removed

modified:src/builtin.c+4 added-1 removed
1278 unmodified lines
1279}12801281#ifdef HAVE_STRPTIME1282static jv f_strptime(jq_state *jq, jv a, jv b) {1283 if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING)1283 if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING) {1284 jv_free(a);1285 jv_free(b);1286 return jv_invalid_with_msg(jv_string("strptime/1 requires string inputs and arguments"));1287 }12881289 struct tm tm;1290 memset(&tm, 0, sizeof(tm));1291 tm.tm_wday = 8; // sentinel
475 unmodified lines
modified:tests/optional.test+1 added
1# See tests/jq.test and the jq manual for more information.23# strptime() is not available on mingw/WIN324[strptime("%Y-%m-%dT%H:%M:%SZ")|(.,mktime)]5"2015-03-05T23:51:47Z"6[[2015,2,5,23,51,47,4,63],1425599507]78# Check day-of-week and day of year computations9# (should trip an assert if this fails)
10 unmodified lines