[Python-checkins] r45259 - in python/trunk: Misc/NEWS Modules/posixmodule.c

"Martin v. Löwis" martin at v.loewis.de
Tue Apr 11 09:23:35 CEST 2006


georg.brandl wrote:
> Modified: python/trunk/Modules/posixmodule.c
> ==============================================================================
> --- python/trunk/Modules/posixmodule.c	(original)
> +++ python/trunk/Modules/posixmodule.c	Tue Apr 11 08:47:43 2006
> @@ -1901,6 +1901,12 @@
>  		}
>  		Py_DECREF(v);
>  	}
> +	if (errno != 0 && d != NULL) {
> +		/* readdir() returned NULL and set errno */
> +		closedir(dirp);
> +		Py_DECREF(d);
> +		return posix_error_with_allocated_filename(name); 
> +	}
>  	closedir(dirp);
>  	PyMem_Free(name);

I believe this patch is incomplete: if readdir succeeds, errno is
not changed. So I think errno must be set to 0 before invoking readdir,
or else you might get bogus exceptions.

Regards,
Martin


More information about the Python-checkins mailing list