ref: c1edf5862950a53253bc0946b9af64ae36d477c5
parent: 9281c68b680507cb2dda3acab7b990521e2451b2
author: Tor Andersson <tor.andersson@artifex.com>
date: Mon Jan 5 14:38:18 EST 2015
Apply short string changes in jsvalue.c as well.
--- a/jsvalue.c
+++ b/jsvalue.c
@@ -281,11 +281,12 @@
case JS_TNUMBER:
p = jsV_numbertostring(J, buf, v->u.number);
if (p == buf) {
- int n = strlen(p);
- if (n < 16) {
+ unsigned int n = strlen(p);
+ if (n <= offsetof(js_Value, type)) {
+ char *s = v->u.shrstr;
+ while (n--) *s++ = *p++;
+ *s = 0;
v->type = JS_TSHRSTR;
- memcpy(v->u.shrstr, p, n);
- v->u.shrstr[n] = 0;
return v->u.shrstr;
} else {
v->type = JS_TMEMSTR;