! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Fix a memory leak in the FreeBSD code
Status:
RESOLVED: FIXED
Product:
Xfce4-diskperf-plugin
Component:
General

Comments

Description Danilo Egea 2014-09-10 18:29:36 CEST
Created attachment 5646 
Fix memory leak

Hello, the patch sent by me has a memory leak bug. I am sending a patch to fix this.
Comment 1 Landry Breuil editbugs 2014-09-10 21:42:26 CEST
Using globals is a bit awkward here.. i'm sure there's a better way. Also, to which patch you sent previously are you reffering to ?
Comment 2 Danilo Egea 2014-09-11 00:09:04 CEST
Created attachment 5647 
New patch
Comment 3 Danilo Egea 2014-09-11 00:09:22 CEST
I sent the patch one year ago [1]

I'm sending a better patch, sorry my fast solution haha :P


http://git.xfce.org/panel-plugins/xfce4-diskperf-plugin/commit/?id=0faba9adc585a02071b4ab1d8761413b4cc35a9a
Comment 4 Landry Breuil editbugs 2014-09-11 07:44:37 CEST
I've looked at the code, and i dont see where there's a leak in the code you  want to change, given that we only use local variables/structures, and none seem malloc'ed at each call.. care to explain a bit more ?
Comment 5 Danilo Egea 2014-09-11 15:23:25 CEST
The function devstat_getdevs allocates a structure devinfo when stats.dinfo is NULL. This should be done just once. In my code I'm using memset to fill both structures with zeros on every call of DevGetPerfData. Thus, devstat_getdevs is allocating a new devinfo every time, but never freeing it. Passing a valid pointer to stats.dinfo avoids the malloc inside devstat_getdevs.
Comment 6 Landry Breuil editbugs 2014-09-11 15:47:18 CEST
Ok, makes sense now - pushed in 5c81437
Comment 7 Danilo Egea 2014-09-11 16:06:23 CEST
Thanks! :)

Bug #11153

Reported by:
Danilo Egea
Reported on: 2014-09-10
Last modified on: 2014-09-11

People

Assignee:
Florian Rivoal
CC List:
1 user

Version

Attachments

Fix memory leak (801 bytes, patch)
2014-09-10 18:29 CEST , Danilo Egea
no flags
New patch (706 bytes, patch)
2014-09-11 00:09 CEST , Danilo Egea
no flags

Additional information