Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: fix for direct array index assignments



Using an array assignment of the form arr=( [2147483648]=x ) fails
because the index is wrapped to a negative value. Large values are
otherwise handled in so far as they lead to malloc() failing and that
causes an error. There's no problem for the more normal assignment
form with arr[2147483648]=x. Credit for finding this problem goes to
Bùi Việt Dũng.

Oliver

diff --git a/Src/params.c b/Src/params.c
index 6210f973f..1fc2a9757 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3411,7 +3411,7 @@ assignaparam(char *s, char **val, int flags)
 	    /*
 	     * This is an ordinary array with key / value pairs.
 	     */
-	    int maxlen, origlen, nextind;
+	    size_t maxlen, origlen, nextind;
 	    char **fullval, **origptr;
 	    zlong *subscripts = (zlong *)zhalloc(arrlen(val) * sizeof(zlong));
 	    zlong *iptr = subscripts;




Messages sorted by: Reverse Date, Date, Thread, Author