summaryrefslogtreecommitdiffstats
path: root/Parser/myreadline.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-06-28 22:00:02 (GMT)
committerGuido van Rossum <guido@python.org>2000-06-28 22:00:02 (GMT)
commit6da3434e037a281c771ad0fe37896920bfedd140 (patch)
tree62e6693804a2140d177126ba0754485ad44862cf /Parser/myreadline.c
parent0ed1148b75de3ab7b969cc22c35bdb6273992954 (diff)
downloadcpython-6da3434e037a281c771ad0fe37896920bfedd140.zip
cpython-6da3434e037a281c771ad0fe37896920bfedd140.tar.gz
cpython-6da3434e037a281c771ad0fe37896920bfedd140.tar.bz2
Trent Mick: familiar simple Win64 patches
Diffstat (limited to 'Parser/myreadline.c')
-rw-r--r--Parser/myreadline.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index 9bf770e..7ce0cdf 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -86,7 +86,7 @@ char *
PyOS_StdioReadline(prompt)
char *prompt;
{
- int n;
+ size_t n;
char *p;
n = 100;
if ((p = PyMem_MALLOC(n)) == NULL)
@@ -95,7 +95,7 @@ PyOS_StdioReadline(prompt)
if (prompt)
fprintf(stderr, "%s", prompt);
fflush(stderr);
- switch (my_fgets(p, n, stdin)) {
+ switch (my_fgets(p, (int)n, stdin)) {
case 0: /* Normal case */
break;
case 1: /* Interrupt */
@@ -116,11 +116,14 @@ PyOS_StdioReadline(prompt)
#endif
n = strlen(p);
while (n > 0 && p[n-1] != '\n') {
- int incr = n+2;
+ size_t incr = n+2;
p = PyMem_REALLOC(p, n + incr);
if (p == NULL)
return NULL;
- if (my_fgets(p+n, incr, stdin) != 0)
+ if (incr > INT_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "input line too long");
+ }
+ if (my_fgets(p+n, (int)incr, stdin) != 0)
break;
n += strlen(p+n);
}