[ZBX-4802] Consider releasing memory taken by strings before calling zbx_vector_str_destroy() Created: 2012 Mar 26  Updated: 2017 May 30  Resolved: 2012 Apr 03

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 2.0.0rc2
Fix Version/s: 2.0.0rc3

Type: Incident report Priority: Trivial
Reporter: Andris Mednis Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: memoryleak
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

zbx_vector_str_destroy() does not release memory used by individual strings contained in the vector. You have to do it explicitly, for example:
....
for (i = 0; i < c_values.values_num; i++)
zbx_free(c_values.values[i]);
zbx_vector_str_destroy(&c_values);
Check Zabbix source code for all places where zbx_vector_str_destroy() is used to avoid memory leaks.



 Comments   
Comment by Andris Mednis [ 2012 Apr 02 ]

zbx_vector_str_destroy() is used in:
src/libs/zbxsysinfo/linux/software.c
src/libs/zbxsysinfo/linux/hardware.c
In both files memory used for strings is de-allocated properly before calling zbx_vector_str_destroy(). src/libs/zbxsysinfo/linux/software.c was slightly changed for clarity (dev. branch ZBX-4802, rev. 26550)

Uses of zbx_vector_ptr_destroy() were also proactively checked. One unclear case was found (see ZBX-4824).

Comment by Alexander Vladishev [ 2012 Apr 02 ]

Successfully tested!

Comment by Andris Mednis [ 2012 Apr 03 ]

Fixed in version 2.0.0rc3(trunk) (revision 26573).

Comment by Andris Mednis [ 2012 Apr 03 ]

Fixed in version 2.0.0rc3(trunk) (revision 26573).

Comment by richlv [ 2012 Sep 11 ]

it's possible this resulted in a regression : ZBX-5571

Comment by Andris Mednis [ 2012 Sep 12 ]

Confirmed: changes done in ZBX-4802 for improving code readability resulted in ZBX-5571.

Generated at Fri Mar 29 02:33:30 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.