aboutsummaryrefslogtreecommitdiffstats
path: root/src/xwidget.c
diff options
context:
space:
mode:
authorPaul Eggert2017-02-10 08:34:57 -0800
committerPaul Eggert2017-02-10 08:36:42 -0800
commitabcba32c262e575b562ec0e481e55538536f969f (patch)
treef873cc4c0190d9e4d77439031eeade3a9a59dc34 /src/xwidget.c
parentcef233eeb8366580f76e8324695e6f964cb160d0 (diff)
downloademacs-abcba32c262e575b562ec0e481e55538536f969f.tar.gz
emacs-abcba32c262e575b562ec0e481e55538536f969f.zip
Fix a few integer-overflow glitches
* src/composite.c (composition_compute_stop_pos, composition_reseat_it): * src/dispextern.h (struct composition_it.rule_idx): * src/keyboard.c (Fset__this_command_keys): * src/xwidget.c (webkit_js_to_lisp): Don’t assume object sizes fit in ‘int’. * src/xwidget.c (Fxwidget_resize): Don’t assume Emacs integers fit in ‘int’.
Diffstat (limited to 'src/xwidget.c')
-rw-r--r--src/xwidget.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index 4ba1617d8df..5c276b1371c 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -301,13 +301,13 @@ webkit_js_to_lisp (JSContextRef context, JSValueRef value)
301 { 301 {
302 JSStringRef pname = JSStringCreateWithUTF8CString("length"); 302 JSStringRef pname = JSStringCreateWithUTF8CString("length");
303 JSValueRef len = JSObjectGetProperty (context, (JSObjectRef) value, pname, NULL); 303 JSValueRef len = JSObjectGetProperty (context, (JSObjectRef) value, pname, NULL);
304 int n = JSValueToNumber (context, len, NULL); 304 EMACS_INT n = JSValueToNumber (context, len, NULL);
305 JSStringRelease(pname); 305 JSStringRelease(pname);
306 306
307 Lisp_Object obj; 307 Lisp_Object obj;
308 struct Lisp_Vector *p = allocate_vector (n); 308 struct Lisp_Vector *p = allocate_vector (n);
309 309
310 for (int i = 0; i < n; ++i) 310 for (ptrdiff_t i = 0; i < n; ++i)
311 { 311 {
312 p->contents[i] = 312 p->contents[i] =
313 webkit_js_to_lisp (context, 313 webkit_js_to_lisp (context,
@@ -323,13 +323,13 @@ webkit_js_to_lisp (JSContextRef context, JSValueRef value)
323 JSPropertyNameArrayRef properties = 323 JSPropertyNameArrayRef properties =
324 JSObjectCopyPropertyNames (context, (JSObjectRef) value); 324 JSObjectCopyPropertyNames (context, (JSObjectRef) value);
325 325
326 int n = JSPropertyNameArrayGetCount (properties); 326 ptrdiff_t n = JSPropertyNameArrayGetCount (properties);
327 Lisp_Object obj; 327 Lisp_Object obj;
328 328
329 /* TODO: can we use a regular list here? */ 329 /* TODO: can we use a regular list here? */
330 struct Lisp_Vector *p = allocate_vector (n); 330 struct Lisp_Vector *p = allocate_vector (n);
331 331
332 for (int i = 0; i < n; ++i) 332 for (ptrdiff_t i = 0; i < n; ++i)
333 { 333 {
334 JSStringRef name = JSPropertyNameArrayGetNameAtIndex (properties, i); 334 JSStringRef name = JSPropertyNameArrayGetNameAtIndex (properties, i);
335 JSValueRef property = JSObjectGetProperty (context, 335 JSValueRef property = JSObjectGetProperty (context,
@@ -733,8 +733,8 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
733 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height) 733 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height)
734{ 734{
735 CHECK_XWIDGET (xwidget); 735 CHECK_XWIDGET (xwidget);
736 CHECK_NATNUM (new_width); 736 CHECK_RANGED_INTEGER (new_width, 0, INT_MAX);
737 CHECK_NATNUM (new_height); 737 CHECK_RANGED_INTEGER (new_height, 0, INT_MAX);
738 struct xwidget *xw = XXWIDGET (xwidget); 738 struct xwidget *xw = XXWIDGET (xwidget);
739 int w = XFASTINT (new_width); 739 int w = XFASTINT (new_width);
740 int h = XFASTINT (new_height); 740 int h = XFASTINT (new_height);