[Home]

Summary:ASTERISK-04281: [patch] uninitialized variable in asterisk.c:main()
Reporter:Luigi Rizzo (rizzo)Labels:
Date Opened:2005-05-26 05:11:30Date Closed:2008-01-15 15:36:55.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) main.diff
Description:at the end of main(), for some unclear reason, the code loops forever
around a poll(). The first argument to poll is used without initializing it.
Ths patch puts it in the only block where it is used, and initializes it
to something sensible - at least we don't have random behaviour in case
the argument is used (which shouldn't, because the second arg. is 0,
but you never know, see below).

NOTE that there are several issues with this block of code. All in all
i think i did the right and safe thing, perhaps whoever commits this can
add one line of explaination on #1 below.

1) why is it there at all ? just to prevent the main program to exit and
  bring its threads with it ?
2) does it have to loop around poll() or could it be something else
  such as sleep() ?
3) if nfds=0 (second argument) then the first argument should be unused,
  so its content should not matter.
  HOWEVER, i am afraid that different systems may behave differently,
  e.g. FreeBSD happily accepts NULL in this case, but the code in poll.c
  requires that the first argument is non-null, and i have no idea about
  other platforms.
Comments:By: Kevin P. Fleming (kpfleming) 2005-06-02 22:39:52

That wait loop was added in bug ASTERISK-2802833, for Darwin/OS X. Your patch looks sane to me, though, so I've committed it to CVS HEAD, thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:36:55.000-0600

Repository: asterisk
Revision: 5826

U   trunk/asterisk.c

------------------------------------------------------------------------
r5826 | kpfleming | 2008-01-15 15:36:54 -0600 (Tue, 15 Jan 2008) | 2 lines

don't call poll() with an unitialized structure (bug ASTERISK-4281)

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

http://svn.digium.com/view/asterisk?view=rev&revision=5826