Mercurial > emacs
diff src/frame.c @ 112440:b5017c649dfb
Check return values of some library calls.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 22 Jan 2011 23:30:19 -0800 |
parents | 9de5a68b57e1 |
children |
line wrap: on
line diff
--- a/src/frame.c Sat Jan 22 20:33:12 2011 -0800 +++ b/src/frame.c Sat Jan 22 23:30:19 2011 -0800 @@ -23,6 +23,8 @@ #include <stdio.h> #include <ctype.h> +#include <errno.h> +#include <limits.h> #include <setjmp.h> #include "lisp.h" #include "character.h" @@ -2149,10 +2151,13 @@ if (len > 1 && str[0] == 'F') { char *end_ptr; - - strtol (str + 1, &end_ptr, 10); - - if (end_ptr == str + len) + long int n; + errno = 0; + n = strtol (str + 1, &end_ptr, 10); + + if (end_ptr == str + len + && INT_MIN <= n && n <= INT_MAX + && ((LONG_MIN < n && n < LONG_MAX) || errno != ERANGE)) return 1; } return 0;