From: Paul Eggert Date: Mon, 23 May 2011 06:58:38 +0000 (-0700) Subject: * ccl.c (ccl_driver): Redo slightly to avoid the need for 'unsigned'. X-Git-Tag: emacs-pretest-24.0.90~104^2~618^2~139^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=519e1d69210be09fc3d541ad3c086c1521f23f26;p=emacs.git * ccl.c (ccl_driver): Redo slightly to avoid the need for 'unsigned'. --- diff --git a/src/ChangeLog b/src/ChangeLog index f49250b6a35..9f9cf401e96 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-05-23 Paul Eggert + * ccl.c (ccl_driver): Redo slightly to avoid the need for 'unsigned'. + ccl: add integer overflow checks * ccl.c (CCL_CODE_MAX, GET_CCL_RANGE, GET_CCL_CODE, GET_CCL_INT): (IN_INT_RANGE): New macros. diff --git a/src/ccl.c b/src/ccl.c index d66a61b713d..98b060522a4 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -946,7 +946,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */ i = reg[RRR]; j = field1 >> 3; - if ((unsigned int) i < j) + if (0 <= i && i < j) GET_CCL_INT (reg[rrr], ccl_prog, ic + i); ic += j; break; @@ -997,7 +997,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */ i = reg[rrr]; GET_CCL_INT (j, ccl_prog, ic); - if ((unsigned int) i < j) + if (0 <= i && i < j) { GET_CCL_INT (i, ccl_prog, ic + 1 + i); CCL_WRITE_CHAR (i); @@ -1019,7 +1019,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size { int incr; GET_CCL_INT (incr, ccl_prog, - ic + ((unsigned int) reg[rrr] < field1 + ic + (0 <= reg[rrr] && reg[rrr] < field1 ? reg[rrr] : field1)); ic += incr; @@ -1114,7 +1114,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ i = reg[rrr]; - if ((unsigned int) i < field1) + if (0 <= i && i < field1) { GET_CCL_INT (j, ccl_prog, ic + i); CCL_WRITE_CHAR (j);