awk: mktime() with no arguments is not allowed

It was SEGVing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2024-07-10 07:04:28 +02:00
parent 2eea3494f1
commit 0a88a7ae3b

View File

@ -509,7 +509,7 @@ static const uint32_t tokeninfo[] ALIGN4 = {
OC_F|F_rn, OC_F|F_si|Nx|Rx, OC_F|F_sq|Nx|Rx, OC_F|F_sr|Nx, // rand sin sqrt srand
OC_B|B_ge|_s_vv_|A3,OC_B|B_gs|ss_vv_|A2,OC_B|B_ix|_ss_vv|A2, // gensub gsub index /*length was here*/
OC_B|B_ma|__s__v|A2,OC_B|B_sp|__s_vv|A2,OC_SPRINTF, OC_B|B_su|ss_vv_|A2,// match split sprintf sub
OC_B|B_ss|__svvv|A2,OC_F|F_ti, OC_B|B_ti|__s_vv, OC_B|B_mt|__s_vv, // substr systime strftime mktime
OC_B|B_ss|__svvv|A2,OC_F|F_ti, OC_B|B_ti|__s_vv, OC_B|B_mt|__s_vv|A1,// substr systime strftime mktime
OC_B|B_lo|__s__v|A1,OC_B|B_up|__s__v|A1, // tolower toupper
OC_F|F_le|Sx, // length
OC_GETLINE|SV, // getline
@ -2870,7 +2870,6 @@ static NOINLINE var *exec_builtin(node *op, var *res)
tt = getvar_i(av[1]);
else
time(&tt);
//s = (nargs > 0) ? as[0] : "%a %b %d %H:%M:%S %Z %Y";
i = strftime(g_buf, MAXVARFMT,
((nargs > 0) ? as[0] : "%a %b %d %H:%M:%S %Z %Y"),
localtime(&tt));