Fix memory leak for battery tooltips

Instead of returning a const string, that is fed into strdup, tooltip
functions are now supposed to return allocated strings. This fixes a
memory leak in the battery tooltip.

This is used instead of simply freeing the memory in the battery
tooltip function, since it also avoids a uselesss strdup().
This commit is contained in:
Sebastian Reichel
2015-08-07 02:03:06 +02:00
parent cbd52d1a48
commit edad9bb7f5
8 changed files with 12 additions and 11 deletions

View File

@@ -304,7 +304,7 @@ void tooltip_copy_text(Area* area)
{
free(g_tooltip.tooltip_text);
if (area && area->_get_tooltip_text)
g_tooltip.tooltip_text = strdup(area->_get_tooltip_text(area));
g_tooltip.tooltip_text = area->_get_tooltip_text(area);
else
g_tooltip.tooltip_text = NULL;
g_tooltip.area = area;