Issue #15989: Fix several occurrences of integer overflow

when result of PyLong_AsLong() narrowed to int without checks.
This commit is contained in:
Serhiy Storchaka 2013-01-15 01:12:17 +02:00
parent 5f1cfbb5c0
commit 7898043868
19 changed files with 148 additions and 24 deletions

View file

@ -13521,7 +13521,7 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx,
"* wants int");
return -1;
}
arg->width = PyLong_AsLong(v);
arg->width = PyLong_AsSsize_t(v);
if (arg->width == -1 && PyErr_Occurred())
return -1;
if (arg->width < 0) {
@ -13568,7 +13568,7 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx,
"* wants int");
return -1;
}
arg->prec = PyLong_AsLong(v);
arg->prec = _PyLong_AsInt(v);
if (arg->prec == -1 && PyErr_Occurred())
return -1;
if (arg->prec < 0)