diff options
Diffstat (limited to 'src/xwidget.c')
| -rw-r--r-- | src/xwidget.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/xwidget.c b/src/xwidget.c index 5a8b105f2fa..791dad43c76 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -310,11 +310,15 @@ webkit_js_to_lisp (JSContextRef context, JSValueRef value) | |||
| 310 | if (JSValueIsArray (context, value)) | 310 | if (JSValueIsArray (context, value)) |
| 311 | { | 311 | { |
| 312 | JSStringRef pname = JSStringCreateWithUTF8CString("length"); | 312 | JSStringRef pname = JSStringCreateWithUTF8CString("length"); |
| 313 | JSValueRef len = JSObjectGetProperty (context, (JSObjectRef) value, pname, NULL); | 313 | JSValueRef len = JSObjectGetProperty (context, (JSObjectRef) value, |
| 314 | EMACS_INT n = JSValueToNumber (context, len, NULL); | 314 | pname, NULL); |
| 315 | double dlen = JSValueToNumber (context, len, NULL); | ||
| 315 | JSStringRelease(pname); | 316 | JSStringRelease(pname); |
| 316 | 317 | ||
| 317 | Lisp_Object obj; | 318 | Lisp_Object obj; |
| 319 | if (! (0 <= dlen && dlen < PTRDIFF_MAX + 1.0)) | ||
| 320 | memory_full (SIZE_MAX); | ||
| 321 | ptrdiff_t n = dlen; | ||
| 318 | struct Lisp_Vector *p = allocate_vector (n); | 322 | struct Lisp_Vector *p = allocate_vector (n); |
| 319 | 323 | ||
| 320 | for (ptrdiff_t i = 0; i < n; ++i) | 324 | for (ptrdiff_t i = 0; i < n; ++i) |
| @@ -333,10 +337,12 @@ webkit_js_to_lisp (JSContextRef context, JSValueRef value) | |||
| 333 | JSPropertyNameArrayRef properties = | 337 | JSPropertyNameArrayRef properties = |
| 334 | JSObjectCopyPropertyNames (context, (JSObjectRef) value); | 338 | JSObjectCopyPropertyNames (context, (JSObjectRef) value); |
| 335 | 339 | ||
| 336 | ptrdiff_t n = JSPropertyNameArrayGetCount (properties); | 340 | size_t n = JSPropertyNameArrayGetCount (properties); |
| 337 | Lisp_Object obj; | 341 | Lisp_Object obj; |
| 338 | 342 | ||
| 339 | /* TODO: can we use a regular list here? */ | 343 | /* TODO: can we use a regular list here? */ |
| 344 | if (PTRDIFF_MAX < n) | ||
| 345 | memory_full (n); | ||
| 340 | struct Lisp_Vector *p = allocate_vector (n); | 346 | struct Lisp_Vector *p = allocate_vector (n); |
| 341 | 347 | ||
| 342 | for (ptrdiff_t i = 0; i < n; ++i) | 348 | for (ptrdiff_t i = 0; i < n; ++i) |