classification
Title: select module uses uninitialized value "tv.tv_usec"
Type: resource usage Stage: resolved
Components: Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benj, christian.heimes, python-dev
Priority: normal Keywords: 3.3regression

Created on 2012-09-11 12:46 by christian.heimes, last changed 2012-09-17 10:24 by jcea. This issue is now closed.

Messages (2)
msg170299 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-09-11 12:46
Starting with Python 3.3 the select module access the uninitialized tv.tv_usec member of a timeval struct. I don't see the point of initializing the local variable long tv_usec from tv.tv_usec. The comment above the code states that long tv_usec is required as a workaround for Mac OS X.

http://hg.python.org/cpython/file/4754c4a710e6/Modules/selectmodule.c#l242

Coverity message:
CID 719694: Uninitialized scalar variable (UNINIT)At (5): Using uninitialized value "tv.tv_usec".
 242        long tv_usec = tv.tv_usec;
 243        if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec) == -1)
 244            return NULL;
 245        tv.tv_usec = tv_usec;

Suggested fix:
change line 242 to "long tv_usec;"
msg170321 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-09-11 16:05
New changeset 6cdc72f4d82c by Benjamin Peterson in branch 'default':
remove useless and defined initialization (closes #15921)
http://hg.python.org/cpython/rev/6cdc72f4d82c
History
Date User Action Args
2012-09-17 10:24:09jceasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2012-09-17 10:23:18jceasetstatus: closed -> open
nosy: + benj

resolution: fixed -> (no value)
stage: resolved -> patch review
2012-09-11 16:05:23python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg170321

resolution: fixed
stage: patch review -> resolved
2012-09-11 12:46:33christian.heimescreate