]> granicus.if.org Git - python/commitdiff
Valgrind was reporting an uninitialized read for bad input.
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 6 Jun 2004 20:13:10 +0000 (20:13 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 6 Jun 2004 20:13:10 +0000 (20:13 +0000)
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.

Modules/binascii.c

index 9cc49f69051cf0938d84a89571e8aa81906195b1..f1f961516a2024d3898345ba339e35d99e2a5cac 100644 (file)
@@ -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