diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-05-23 15:44:34 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-05-23 15:44:34 +0800 |
commit | 98de18c4a1881cdd38e00eb4e07664a9c9c6a1f6 (patch) | |
tree | e589e469290f6b0e66b418fd7f4906d30f5d0eb9 | |
parent | ec05878378bf14ad85aa07a9762ea00b99bc672f (diff) |
No options shouldn't iterate to -1
-rw-r--r-- | ord.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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]); |