Closed ThomasDickey closed 1 year ago
kwanyyoss commented
If "sval" were NULL, after jumping to "error:", the line:
TRACE(("...bi_mktime(%s) ->%s", sval->str, ctime(&result)));
would dereference the NULL "sval".
If I were you, I would do a minimal fix like this:
@@ -471,6 +471,10 @@
TRACE_FUNC("bi_mktime", sp);
+ if (!sval) {
+ result = -1;
+ goto bi_mktime_done;
+ }
memset(&my_tm, 0, sizeof(my_tm));
switch (sscanf(sval->str, "%d %d %d %d %d %d %d",
&my_tm.tm_year,
@@ -498,7 +502,7 @@
result = mktime(&my_tm);
}
TRACE(("...bi_mktime(%s) ->%s", sval->str, ctime(&result)));
-
+bi_mktime_done:
cell_destroy(sp);
sp->type = C_DOUBLE;
sp->dval = (double) result;
added a null-pointer check
see https://github.com/ThomasDickey/mawk-snapshots/issues/5