This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyOS_ascii_strtod() uses malloc() directly
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, georg.brandl, tim.peters
Priority: normal Keywords:

Created on 2006-05-25 00:51 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg28632 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2006-05-25 00:51
Line 103 shows a use of a bare malloc() instead of the
proper memory-related macro.
msg28633 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-05-25 01:18
Logged In: YES 
user_id=31435

Well, it's not really a bug.  If a module wants to use
malloc/free internally, that's fine.  I can't think of a
reason for _why_ this code wants to do that, but it doesn't
really hurt.

Somtimes there is a good reason.  For example, the code
providing a portable notion of thread-local storage in
thread.c uses malloc deliberately, because those functions
can be called when the GIL isn't held (i.e., multiple
threads can call them simultaneously).  The Python memory
families, like almost all parts of the Python C API, are
free to assume that the GIL is held; in particular, obmalloc
does assume that, so it would be disastrous if thread.c used
that memory family instead.
msg28634 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2006-05-25 20:24
Logged In: YES 
user_id=357491

OK.  Well, considered it is free within the function and all
memory use is done through C API functions (memcpy() and
strtod() specifically, I don't see any reason not to move
over to PyMem_Malloc() since I can do that quickly.

Oh, and the file is Python/pystrtod.c and it's line 104 for
those who don't know where the function is.
msg28635 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2006-05-25 20:45
Logged In: YES 
user_id=357491

Changed in rev. 46253 to use PyMem_MALLOC/PyMem_FREE .
msg28636 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-25 21:45
Logged In: YES 
user_id=849994

Reopening as there is no check for the return value of
malloc, as Tim noticed on python-cvs.
msg28637 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-29 14:28
Logged In: YES 
user_id=849994

Added a NULL handler in rev. 46524.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43408
2006-05-25 00:51:53brett.cannoncreate