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:
@@ -144,10 +144,10 @@ struct tm* clock_gettime_for_tz(const char* timezone) {
|
||||
else return localtime(&time_clock.tv_sec);
|
||||
}
|
||||
|
||||
const char* clock_get_tooltip(void* obj)
|
||||
char* clock_get_tooltip(void* obj)
|
||||
{
|
||||
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));
|
||||
return buf_tooltip;
|
||||
return strdup(buf_tooltip);
|
||||
}
|
||||
|
||||
int time_format_needs_sec_ticks(char *time_format)
|
||||
|
||||
Reference in New Issue
Block a user