[Python-checkins] python/dist/src/Modules binascii.c,2.38,2.39
twouters@users.sourceforge.net
twouters@users.sourceforge.net
Mon, 17 Mar 2003 03:24:32 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv14143/Modules
Modified Files:
binascii.c
Log Message:
binascii_a2b_base64: Properly return an empty string if the input was all
invalid, rather than returning a string of random garbage of the
estimated result length. Closes SF patch #703471 by Hye-Shik Chang.
Will backport to 2.2-maint (consider it done.)
Index: binascii.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/binascii.c,v
retrieving revision 2.38
retrieving revision 2.39
diff -C2 -d -r2.38 -r2.39
*** binascii.c 15 Aug 2002 22:14:24 -0000 2.38
--- binascii.c 17 Mar 2003 11:24:29 -0000 2.39
***************
*** 409,415 ****
}
! /* and set string size correctly */
if (bin_len > 0)
_PyString_Resize(&rv, bin_len);
return rv;
}
--- 409,422 ----
}
! /* And set string size correctly. If the result string is empty
! ** (because the input was all invalid) return the shared empty
! ** string instead; _PyString_Resize() won't do this for us.
! */
if (bin_len > 0)
_PyString_Resize(&rv, bin_len);
+ else {
+ Py_DECREF(rv);
+ rv = PyString_FromString("");
+ }
return rv;
}