Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Re: [Python-checkins] cpython: avoid unitialized memory

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


eric at trueblade

May 4, 2012, 1:21 AM

Post #1 of 4 (237 views)
Permalink
Re: [Python-checkins] cpython: avoid unitialized memory

On 5/4/2012 1:14 AM, benjamin.peterson wrote:
> http://hg.python.org/cpython/rev/b0deafca6c02
> changeset: 76743:b0deafca6c02
> user: Benjamin Peterson <benjamin [at] python>
> date: Fri May 04 01:14:03 2012 -0400
> summary:
> avoid unitialized memory
>
> files:
> Modules/posixmodule.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>
> diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
> --- a/Modules/posixmodule.c
> +++ b/Modules/posixmodule.c
> @@ -3576,7 +3576,7 @@
> split_py_long_to_s_and_ns(PyObject *py_long, time_t *s, long *ns)
> {
> int result = 0;
> - PyObject *divmod;
> + PyObject *divmod = NULL;
> divmod = PyNumber_Divmod(py_long, billion);

How is that uninitialized if it's being set on the next line?

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


stefan at bytereef

May 4, 2012, 2:39 AM

Post #2 of 4 (225 views)
Permalink
Re: [Python-checkins] cpython: avoid unitialized memory [In reply to]

benjamin.peterson <python-checkins [at] python> wrote:
> summary:
> avoid unitialized memory
>
> diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
> --- a/Modules/posixmodule.c
> +++ b/Modules/posixmodule.c
> @@ -3576,7 +3576,7 @@
> split_py_long_to_s_and_ns(PyObject *py_long, time_t *s, long *ns)
> {
> int result = 0;
> - PyObject *divmod;
> + PyObject *divmod = NULL;
> divmod = PyNumber_Divmod(py_long, billion);
> if (!divmod)
> goto exit;

If I'm not mistaken, divmod was already unconditionally initialized
by PyNumber_Divmod().


Stefan Krah


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


stephen at xemacs

May 4, 2012, 5:33 AM

Post #3 of 4 (223 views)
Permalink
Re: [Python-checkins] cpython: avoid unitialized memory [In reply to]

Eric V. Smith writes:

> > - PyObject *divmod;
> > + PyObject *divmod = NULL;
> > divmod = PyNumber_Divmod(py_long, billion);
>
> How is that uninitialized if it's being set on the next line?

Maybe they finally developed a Sufficiently Stupid Compiler?

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


benjamin at python

May 4, 2012, 8:06 AM

Post #4 of 4 (228 views)
Permalink
Re: [Python-checkins] cpython: avoid unitialized memory [In reply to]

2012/5/4 Eric V. Smith <eric [at] trueblade>:
> On 5/4/2012 1:14 AM, benjamin.peterson wrote:
>> http://hg.python.org/cpython/rev/b0deafca6c02
>> changeset:   76743:b0deafca6c02
>> user:        Benjamin Peterson <benjamin [at] python>
>> date:        Fri May 04 01:14:03 2012 -0400
>> summary:
>>   avoid unitialized memory
>>
>> files:
>>   Modules/posixmodule.c |  2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>>
>> diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
>> --- a/Modules/posixmodule.c
>> +++ b/Modules/posixmodule.c
>> @@ -3576,7 +3576,7 @@
>>  split_py_long_to_s_and_ns(PyObject *py_long, time_t *s, long *ns)
>>  {
>>      int result = 0;
>> -    PyObject *divmod;
>> +    PyObject *divmod = NULL;
>>      divmod = PyNumber_Divmod(py_long, billion);
>
> How is that uninitialized if it's being set on the next line?

It was a misreading on my part.

--
Regards,
Benjamin
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.