[haiku-bugs] Re: [Haiku] #10733: [BOptionPopUp] can crash when containing a SeparatorItem

  • From: "ttcoder" <trac@xxxxxxxxxxxx>
  • Date: Tue, 01 Apr 2014 15:23:18 -0000

#10733: [BOptionPopUp] can crash when containing a SeparatorItem
----------------------------------+----------------------------
   Reporter:  ttcoder             |      Owner:  axeld
       Type:  bug                 |     Status:  new
   Priority:  normal              |  Milestone:  R1
  Component:  Kits/Interface Kit  |    Version:  R1/Development
 Resolution:                      |   Keywords:
 Blocked By:                      |   Blocking:
Has a Patch:  0                   |   Platform:  All
----------------------------------+----------------------------

Comment (by ttcoder):

 I guess this diff would be best, as this returns false when the field is
 not present (by opposed to testing for the field only later down in the
 inner if() ):

 {{{
 --- a/src/kits/interface/OptionPopUp.cpp
 +++ b/src/kits/interface/OptionPopUp.cpp
 @@ -104,7 +104,7 @@ BOptionPopUp::GetOptionAt(int32 index, const char**
 outName,

         if (menu != NULL) {
                 BMenuItem* item = menu->ItemAt(index);
 -               if (item != NULL) {
 +               if (item != NULL && item->Message() != NULL) {
                         if (outName != NULL)
                                 *outName = item->Label();
                         if (outValue != NULL)
 }}}


 Here's the stack crawl BTW:

 {{{
                 state: Exception (Segment violation)

                 Frame           IP                      Function Name
                 -----------------------------------------------
                 0x635ecbf8      0xf3cc20
 BMessage::_FindField(BMessage, char*, uint32, BMessage::field_header*) +
 0x28
                         Frame memory:
                         [0x635ecbd8]  .x........^c6...   f8 78 13 01 00 00
 00 00 e0 cc 5e 63 36 ce f3 00
                         [0x635ecbe8]  .....Z..0.^cm...   8d 9c a8 03 d4 5a
 9a 00 30 cc 5e 63 6d d3 f3 00
                 0x635ecc38      0xf3d368
 BMessage::FindData(BMessage, char*, uint32, int32, void*, void*) + 0x48
                 0x635ecc88      0xf3ecd2
 BMessage::FindInt32(BMessage, char*, void*) + 0x46
                 0x635eccb8      0xfaff5f
 BOptionPopUp::GetOptionAt(int32, char*, void*) + 0x83
 }}}

--
Ticket URL: <https://dev.haiku-os.org/ticket/10733#comment:1>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: