[Patches] [ python-Patches-683187 ] universal newline problems on error

SourceForge.net noreply@sourceforge.net
Sat, 08 Feb 2003 16:48:08 -0800


Patches item #683187, was opened at 2003-02-08 19:48
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=683187&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Jack Jansen (jackjansen)
Summary: universal newline problems on error

Initial Comment:
Jack, I think there are 2 problems with the current
code in Py_UniversalNewlineFread().

First, the return type is size_t.  Since fread()
returns 0 on error, this function should also return 0.
 (That seems to be how the callers expect an error.) 
Currently it returns -1 if the file object pointer is
NULL or not a PyFileObject.  Note: there is a return
fread(...); if not using universal newlines.

Second, (see line 2295) if fread() returns an error,
src will contain uninitialized data in the inner while
loop which will be accessed.  The patch breaks from the
outer while loop when fread() returns 0.

Do these make sense?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=683187&group_id=5470