aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Crash on amulegui 20080331  (Read 1858 times)

xor

  • Approved Newbie
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 11
Crash on amulegui 20080331
« on: March 31, 2008, 02:35:19 PM »

Hi guys.

I've compiled last SVN version, 20080331 on a mac os x 10.5.2, G5 PPC. The new code in OScopeCtrl.cpp causes amulegui to crash.

The reason: in function OnSize, lines 349-350, the width and height of rectPlot are calculated using a max *unsigned* function. The problem is that sometimes m_rectClient.GetBottom() - 25 gives negative numbers, and converting them to unsigned makes huge numbers. After that, when line 362 creates a new bitmap (m_bmapPlot.Create()), it crashes because it doens't have enough memory.

I've patched it just changing these lines:

   m_rectPlot.SetRight(std::max<unsigned>(m_rectPlot.GetLeft() + 1, m_rectClient.GetRight() - 40));
   m_rectPlot.SetBottom(std::max<unsigned>(m_rectPlot.GetTop() + 1, m_rectClient.GetBottom() - 25));

by:

   m_rectPlot.SetRight(std::max<int>(m_rectPlot.GetLeft() + 1, m_rectClient.GetRight() - 40));
   m_rectPlot.SetBottom(std::max<int>(m_rectPlot.GetTop() + 1, m_rectClient.GetBottom() - 25));

this way the maximum is well calculated.
Logged

Xaignar

  • Admin and Code Junky
  • Hero Member
  • *****
  • Karma: 19
  • Offline Offline
  • Posts: 1103
Re: Crash on amulegui 20080331
« Reply #1 on: March 31, 2008, 05:21:17 PM »

Thanks for the patch, I'll commit it ASAP.
Logged