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 7e4e722
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion make.py
Expand Up @@ -9,7 +9,11 @@
def output_on_failure(cmd, cwd):
print(f'$ cd {cwd} && {cmd}')
ret = subprocess.run(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd,
cmd,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
if ret.returncode:
raise AssertionError('Command {!r} returned {}!\nOutput:\n{}'.format(
Expand Down
6 changes: 5 additions & 1 deletion make0x.py
Expand Up @@ -9,7 +9,11 @@
def output_on_failure(cmd, cwd):
print(f'$ cd {cwd} && {cmd}')
ret = subprocess.run(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd,
cmd,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
if ret.returncode:
raise AssertionError('Command {!r} returned {}!\nOutput:\n{}'.format(
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 7e4e722

Please sign in to comment.