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

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


Patches item #683187, was opened at 2003-02-09 01: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: Neal Norwitz (nnorwitz)
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?

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

>Comment By: Jack Jansen (jackjansen)
Date: 2003-02-09 02:06

Message:
Logged In: YES 
user_id=45365

I haven't tested the patch as my Python is broken right now, but from the description and inspecting the code it makes perfect sense. Go ahead and check it in!

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

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