Commit 815acb3b authored by Guido van Rossum's avatar Guido van Rossum

unpack_string(): avoid a compiler warning (about a real bug!) by

copying the result of fgetc() into an int variable before testing it
for EOF.
parent db7b5fd2
...@@ -305,6 +305,7 @@ unpack_string(LogReaderObject *self, PyObject **pvalue) ...@@ -305,6 +305,7 @@ unpack_string(LogReaderObject *self, PyObject **pvalue)
int i; int i;
int len; int len;
int err; int err;
int ch;
char *buf; char *buf;
if ((err = unpack_packed_int(self, &len, 0))) if ((err = unpack_packed_int(self, &len, 0)))
...@@ -312,7 +313,9 @@ unpack_string(LogReaderObject *self, PyObject **pvalue) ...@@ -312,7 +313,9 @@ unpack_string(LogReaderObject *self, PyObject **pvalue)
buf = malloc(len); buf = malloc(len);
for (i=0; i < len; i++) { for (i=0; i < len; i++) {
if ((buf[i] = fgetc(self->logfp)) == EOF) { ch = fgetc(self->logfp);
buf[i] = ch;
if (ch == EOF) {
free(buf); free(buf);
return ERR_EOF; return ERR_EOF;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment