summaryrefslogtreecommitdiff
path: root/parse/fold.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-11 22:06:57 -0500
committerOri Bernstein <ori@eigenstate.org>2016-01-11 22:08:59 -0500
commit6c80892463e0ae42dfd5bbce14adbaad1624ad93 (patch)
tree0fd22341289e0a64e4f3bfc375b0519ef025e00a /parse/fold.c
parent8fda8a0adbb44f4e63bb86256d9f56700d79f301 (diff)
downloadmc-6c80892463e0ae42dfd5bbce14adbaad1624ad93.tar.gz
Don't sort or copy zero-length null arrays.
It's sensible, but undefined.
Diffstat (limited to 'parse/fold.c')
-rw-r--r--parse/fold.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse/fold.c b/parse/fold.c
index 0687a85..02b37e2 100644
--- a/parse/fold.c
+++ b/parse/fold.c
@@ -221,7 +221,8 @@ Node *fold(Node *n, int foldvar)
}
break;
case Oarr:
- qsort(n->expr.args, n->expr.nargs, sizeof(Node*), idxcmp);
+ if (n->expr.nargs > 0)
+ qsort(n->expr.args, n->expr.nargs, sizeof(Node*), idxcmp);
break;
case Ocast:
r = foldcast(n);