diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2004-06-06 20:13:10 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2004-06-06 20:13:10 (GMT) |
commit | fe92eef85b081640e20b787c99282544e148fc1c (patch) | |
tree | c60317ab670f8cc749ec5cb89efc03390b86c256 | |
parent | 7b0a5057afaadab77aa20f87681edd89e327ea3c (diff) | |
download | cpython-fe92eef85b081640e20b787c99282544e148fc1c.zip cpython-fe92eef85b081640e20b787c99282544e148fc1c.tar.gz cpython-fe92eef85b081640e20b787c99282544e148fc1c.tar.bz2 |
Valgrind was reporting an uninitialized read for bad input.
This fixes the problem and the test passes. I'm not sure
the test is really correct though. It seems like it would
be better to raise an exception. I think that wasn't done
for backwards compatability.
Bugfix candidate.
-rw-r--r-- | Modules/binascii.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c index 9cc49f6..f1f9615 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -204,7 +204,8 @@ binascii_a2b_uu(PyObject *self, PyObject *args) bin_data = (unsigned char *)PyString_AsString(rv); for( ; bin_len > 0 ; ascii_len--, ascii_data++ ) { - this_ch = *ascii_data; + /* XXX is it really best to add NULs if there's no more data */ + this_ch = (ascii_len > 0) ? *ascii_data : 0; if ( this_ch == '\n' || this_ch == '\r' || ascii_len <= 0) { /* ** Whitespace. Assume some spaces got eaten at |