aMule Forum

English => en_Bugs => Topic started by: xor on March 31, 2008, 02:35:19 PM

Title: Crash on amulegui 20080331
Post by: xor 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.
Title: Re: Crash on amulegui 20080331
Post by: Xaignar on March 31, 2008, 05:21:17 PM
Thanks for the patch, I'll commit it ASAP.