Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Add int multiplication overflow check & fix make's std output
Browse files Browse the repository at this point in the history
  • Loading branch information
int3l committed Sep 18, 2021
1 parent ad7243a commit 0af279d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion make.py
Expand Up @@ -13,7 +13,7 @@ def output_on_failure(cmd, cwd):
)
if ret.returncode:
raise AssertionError('Command {!r} returned {}!\nOutput:\n{}'.format(
cmd, ret.returncode, ret.stdout,
cmd, ret.returncode, ret.stdout.decode(),
))


Expand Down
2 changes: 1 addition & 1 deletion make0x.py
Expand Up @@ -13,7 +13,7 @@ def output_on_failure(cmd, cwd):
)
if ret.returncode:
raise AssertionError('Command {!r} returned {}!\nOutput:\n{}'.format(
cmd, ret.returncode, ret.stdout,
cmd, ret.returncode, ret.stdout.decode(),
))


Expand Down
7 changes: 5 additions & 2 deletions python-0.9.1/src/intobject.c
Expand Up @@ -188,14 +188,17 @@ int_mul(v, w)
intobject *v;
register object *w;
{
register long a, b;
register long a, b, x;
if (!is_intobject(w)) {
err_badarg();
return NULL;
}
a = v->ob_ival;
b = ((intobject *)w) -> ob_ival;
return newintobject(a * b);
x = a * b;
if ( a != 0 && x / a != b)
return err_ovf();
return newintobject(x);
}

static object *
Expand Down

0 comments on commit 0af279d

Please sign in to comment.