shithub: libmujs

Download patch

ref: 6b522a0b1f8559a78341a3c7163772b2f41d9a54
parent: 6e62eb0923b6648387ae045623836ed18d476159
author: Tor Andersson <tor.andersson@artifex.com>
date: Thu Nov 28 06:30:54 EST 2019

Issue 115: Fix compilation of small floating point numbers.

The check for whether a number is an integer or not failed on number
too small because we were using an addition in the test.

--- a/jscompile.c
+++ b/jscompile.c
@@ -192,16 +192,12 @@
 		emitarg(J, F, 32768);
 		if (signbit(num))
 			emit(J, F, OP_NEG);
+	} else if (num >= SHRT_MIN && num <= SHRT_MAX && num == (int)num) {
+		emit(J, F, OP_INTEGER);
+		emitarg(J, F, num + 32768);
 	} else {
-		double nv = num + 32768;
-		js_Instruction iv = nv;
-		if (nv == iv) {
-			emit(J, F, OP_INTEGER);
-			emitarg(J, F, iv);
-		} else {
-			emit(J, F, OP_NUMBER);
-			emitarg(J, F, addnumber(J, F, num));
-		}
+		emit(J, F, OP_NUMBER);
+		emitarg(J, F, addnumber(J, F, num));
 	}
 }