1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Fix leak on error in strptime

This commit is contained in:
Nicolas Williams
2017-11-23 01:51:22 -06:00
parent bdaddcf107
commit 18879fb993
2 changed files with 5 additions and 1 deletions

View File

@ -1280,8 +1280,11 @@ static void set_tm_yday(struct tm *tm) {
#ifdef HAVE_STRPTIME
static jv f_strptime(jq_state *jq, jv a, jv b) {
if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING)
if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING) {
jv_free(a);
jv_free(b);
return jv_invalid_with_msg(jv_string("strptime/1 requires string inputs and arguments"));
}
struct tm tm;
memset(&tm, 0, sizeof(tm));

View File

@ -2,6 +2,7 @@
# strptime() is not available on mingw/WIN32
[strptime("%Y-%m-%dT%H:%M:%SZ")|(.,mktime)]
"2015-03-05T23:51:47Z"
[[2015,2,5,23,51,47,4,63],1425599507]
# Check day-of-week and day of year computations