diff options
| author | Paul Eggert | 2011-06-15 12:57:25 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-15 12:57:25 -0700 |
| commit | a7af7fdede602a111401c2352e81311a9dc38b99 (patch) | |
| tree | daebcb8a73345231337d0a461c01ae7804b2b646 /src/bytecode.c | |
| parent | 8c9b210626493dd93f236d7fb312c4f6dba62892 (diff) | |
| parent | b1c46f026de9d185ba86ffb1b23c50f2bd095ccf (diff) | |
| download | emacs-a7af7fdede602a111401c2352e81311a9dc38b99.tar.gz emacs-a7af7fdede602a111401c2352e81311a9dc38b99.zip | |
Integer overflow and signedness fixes (Bug#8873).
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 74cf401bf1d..58b26c79b84 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -433,7 +433,7 @@ If the third argument is incorrect, Emacs may crash. */) | |||
| 433 | 433 | ||
| 434 | Lisp_Object | 434 | Lisp_Object |
| 435 | exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | 435 | exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, |
| 436 | Lisp_Object args_template, int nargs, Lisp_Object *args) | 436 | Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) |
| 437 | { | 437 | { |
| 438 | int count = SPECPDL_INDEX (); | 438 | int count = SPECPDL_INDEX (); |
| 439 | #ifdef BYTE_CODE_METER | 439 | #ifdef BYTE_CODE_METER |
| @@ -444,7 +444,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 444 | /* Lisp_Object v1, v2; */ | 444 | /* Lisp_Object v1, v2; */ |
| 445 | Lisp_Object *vectorp; | 445 | Lisp_Object *vectorp; |
| 446 | #ifdef BYTE_CODE_SAFE | 446 | #ifdef BYTE_CODE_SAFE |
| 447 | int const_length; | 447 | ptrdiff_t const_length; |
| 448 | Lisp_Object *stacke; | 448 | Lisp_Object *stacke; |
| 449 | int bytestr_length; | 449 | int bytestr_length; |
| 450 | #endif | 450 | #endif |
| @@ -464,7 +464,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 464 | 464 | ||
| 465 | CHECK_STRING (bytestr); | 465 | CHECK_STRING (bytestr); |
| 466 | CHECK_VECTOR (vector); | 466 | CHECK_VECTOR (vector); |
| 467 | CHECK_NUMBER (maxdepth); | 467 | CHECK_NATNUM (maxdepth); |
| 468 | 468 | ||
| 469 | #ifdef BYTE_CODE_SAFE | 469 | #ifdef BYTE_CODE_SAFE |
| 470 | const_length = ASIZE (vector); | 470 | const_length = ASIZE (vector); |
| @@ -486,6 +486,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 486 | stack.byte_string = bytestr; | 486 | stack.byte_string = bytestr; |
| 487 | stack.pc = stack.byte_string_start = SDATA (bytestr); | 487 | stack.pc = stack.byte_string_start = SDATA (bytestr); |
| 488 | stack.constants = vector; | 488 | stack.constants = vector; |
| 489 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) < XFASTINT (maxdepth)) | ||
| 490 | memory_full (SIZE_MAX); | ||
| 489 | top = (Lisp_Object *) alloca (XFASTINT (maxdepth) | 491 | top = (Lisp_Object *) alloca (XFASTINT (maxdepth) |
| 490 | * sizeof (Lisp_Object)); | 492 | * sizeof (Lisp_Object)); |
| 491 | #if BYTE_MAINTAIN_TOP | 493 | #if BYTE_MAINTAIN_TOP |
| @@ -502,14 +504,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 502 | 504 | ||
| 503 | if (INTEGERP (args_template)) | 505 | if (INTEGERP (args_template)) |
| 504 | { | 506 | { |
| 505 | int at = XINT (args_template); | 507 | ptrdiff_t at = XINT (args_template); |
| 506 | int rest = at & 128; | 508 | int rest = at & 128; |
| 507 | int mandatory = at & 127; | 509 | int mandatory = at & 127; |
| 508 | int nonrest = at >> 8; | 510 | ptrdiff_t nonrest = at >> 8; |
| 509 | eassert (mandatory <= nonrest); | 511 | eassert (mandatory <= nonrest); |
| 510 | if (nargs <= nonrest) | 512 | if (nargs <= nonrest) |
| 511 | { | 513 | { |
| 512 | int i; | 514 | ptrdiff_t i; |
| 513 | for (i = 0 ; i < nargs; i++, args++) | 515 | for (i = 0 ; i < nargs; i++, args++) |
| 514 | PUSH (*args); | 516 | PUSH (*args); |
| 515 | if (nargs < mandatory) | 517 | if (nargs < mandatory) |
| @@ -528,7 +530,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 528 | } | 530 | } |
| 529 | else if (rest) | 531 | else if (rest) |
| 530 | { | 532 | { |
| 531 | int i; | 533 | ptrdiff_t i; |
| 532 | for (i = 0 ; i < nonrest; i++, args++) | 534 | for (i = 0 ; i < nonrest; i++, args++) |
| 533 | PUSH (*args); | 535 | PUSH (*args); |
| 534 | PUSH (Flist (nargs - nonrest, args)); | 536 | PUSH (Flist (nargs - nonrest, args)); |