[ZBX-12036] Memory leak in zabbix_get Created: 2017 Apr 11  Updated: 2017 Aug 17  Resolved: 2017 Aug 17

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 2.2.17
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Andrea Biscuola (Inactive) Assignee: Unassigned
Resolution: Won't fix Votes: 0
Labels: agent, memory
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File ZBX-12036.patch    
Sprint: Sprint 14
Story Points: 0.5

 Description   

src/zabbix_get/zabbix_get.c:184

	/* parse the command-line */
	while ((char)EOF != (ch = (char)zbx_getopt_long(argc, argv, shortopts, longopts, NULL)))
	{
		switch (ch)
		{
			case 'k':
				key = strdup(zbx_optarg);
				break;
			case 'p':
				port = (unsigned short)atoi(zbx_optarg);
				break;
			case 's':
				host = strdup(zbx_optarg);
				break;
			case 'I':
				source_ip = strdup(zbx_optarg);
				break;
			case 'h':
				help();
				exit(-1);
				break;
			case 'V':
				version();
				exit(-1);
				break;
			default:
				usage();
				exit(-1);
				break;
		}
	}

the variable source_ip allocated dynamically by strdup() is never freed. 3.0, 3.2 and trunk are not affected as the source_ip variables is properly freed in the out goto label.

Spotted by the clang static analyzer



 Comments   
Comment by wangbin [ 2017 Aug 09 ]

add
zbx_free(source_ip);

Comment by Alexander Vladishev [ 2017 Aug 17 ]

Full support 2.2 will be finished soon. I close this issue.

Generated at Thu Mar 28 13:10:50 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.