shithub: libmujs

Download patch

ref: ddd770933bded000ad332f551892e061498e74d1
parent: db212180bfa53e3dccf36f999a5defcf1676a25e
author: Tor Andersson <tor.andersson@artifex.com>
date: Mon May 8 08:36:05 EDT 2023

Handle sign when converting integer strings to numbers.

--- a/jsvalue.c
+++ b/jsvalue.c
@@ -205,8 +205,15 @@
 	}
 	if (isflt)
 		n = js_strtod(s, &end);
-	else
-		n = js_strtol(s, &end, 10);
+	else {
+		/* js_strtol doesn't parse the sign */
+		if (*s == '-')
+			n = -js_strtol(s+1, &end, 10);
+		else if (*s == '+')
+			n = js_strtol(s+1, &end, 10);
+		else
+			n = js_strtol(s, &end, 10);
+	}
 	if (end == e) {
 		*ep = (char*)e;
 		return n;