From 98de18c4a1881cdd38e00eb4e07664a9c9c6a1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 23 May 2023 15:44:34 +0800 Subject: No options shouldn't iterate to -1 --- ord.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ord.c b/ord.c index 9e15a5b..c1f79cc 100644 --- a/ord.c +++ b/ord.c @@ -25,9 +25,7 @@ void interchange_ord_order(const char *sku, const char *item, } for (size_t i = 0; i < nopts; i++) --options; - if (nopts) - nopts++; - size_t total_nopts = 4 + nopts; + size_t total_nopts = 4 + (nopts ? 1 : 0) + nopts; const char *order[total_nopts + 1][2]; order[0][0] = "mv_action"; order[0][1] = "refresh"; @@ -42,7 +40,7 @@ void interchange_ord_order(const char *sku, const char *item, order[4][0] = "mv_form_profile"; order[4][1] = "check_opt"; } - for (size_t i = 0; i < nopts - 1; i++) { + for (size_t i = 0; i < nopts; i++) { const char **pair = options[i]; order[5 + i][0] = malloc(strlen(prefix) + strlen(pair[0]) + 1); sprintf((char *)order[5 + i][0], "%s%s", prefix, pair[0]); -- cgit v1.2.3