On Mon, Apr 05, 2010 at 10:32:44PM +0200, Tamas TEVESZ wrote:
> 
> 149                         if (len > 0) {
> 150                                 WMList *lPtr;
> 151                                 int i;
> 152 
> 153                                 if (w == panel->icoaB)
> 154                                         lPtr = panel->icoL;
> 155                                 else if (w == panel->pixaB)
> 156                                         lPtr = panel->pixL;
> 157                                 else return;
> 158 
> 159                                 i = WMGetListSelectedItemRow(lPtr);
> 160                                 if (i >= 0)
> 161                                         i++;
> 162                                 addPathToList(lPtr, i, str);
> 163                                 WMSetListBottomPosition(lPtr, 
> WMGetListNumberOfRows(lPtr));
> 164 
> 165                                 wfree(str);
> 166                         }
> 
> unless i should really be sleeping, the return is either bogus, or 
> 158-165 should quite be killed, no?

Go get some sleep ;) There are three possibilities in this bit of code:
  1. w is panel->icoaB, in which case lPtr is panel->icoL
  2. w is panel->pixaB, in which case lPtr is panel->pixL
  3. w is something else, in which case lPtr is uninitialized garbage
Without the return, the code would happily pass the garbage pointer and
quite possibly wind up with a segfault. With the return, it just does
nothing. It may be that something other than "do nothing" is the correct
behavior, but since it looks like case #3 is a "can never happen" case
it really doesn't matter too much. Maybe change the return to an
explicit "scream and die" then?


-- 
To unsubscribe, send mail to [email protected].

Reply via email to