[haiku-bugs] Re: [Haiku] #11111: Division by zero in TabDecorator CID 1210846 (easy)

  • From: "pulkomandy" <trac@xxxxxxxxxxxx>
  • Date: Thu, 29 Jan 2015 17:02:50 -0000

#11111: Division by zero in TabDecorator CID 1210846 (easy)
----------------------------------+----------------------------
   Reporter:  kallisti5           |      Owner:  axeld
       Type:  bug                 |     Status:  new
   Priority:  low                 |  Milestone:  R1
  Component:  Servers/app_server  |    Version:  R1/Development
 Resolution:                      |   Keywords:
 Blocked By:                      |   Blocking:
Has a Patch:  1                   |   Platform:  All
----------------------------------+----------------------------

Comment (by pulkomandy):

 This isn't a clean way to handle this. What I would do is:
 * Store the value of CountTabs in a local variable (tabCount or so)
 * ASSERT on the variable, then use it for the loop

 This makes sure the assert and the loop use the same bound (it doesn't
 look like there is any locking, so in the current code a tab could be
 removed while the function runs?).

 Then, I would also add a NULL check on the tab inside the loop (and skip
 the tab if it is NULL)

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

Other related posts: