| [ZBX-15090] Memory leak when trying to use regexp_compile() for regular expression validation Created: 2018 Oct 30 Updated: 2024 Apr 10 Resolved: 2018 Nov 02 | |
| Status: | Closed | 
| Project: | ZABBIX BUGS AND ISSUES | 
| Component/s: | Proxy (P), Server (S) | 
| Affects Version/s: | 4.0.1rc2, 4.2.0alpha1 | 
| Fix Version/s: | 4.0.2rc1, 4.2.0alpha1, 4.2 (plan) | 
| Type: | Problem report | Priority: | Major | 
| Reporter: | Andris Zeila | Assignee: | Andris Zeila | 
| Resolution: | Fixed | Votes: | 0 | 
| Labels: | memoryleak | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Team: | |
| Sprint: | Sprint 46, Nov 2018 | 
| Story Points: | 0.125 | 
| Description | 
| Index: src/libs/zbxregexp/zbxregexp.c
===================================================================
--- src/libs/zbxregexp/zbxregexp.c	(revision 86088)
+++ src/libs/zbxregexp/zbxregexp.c	(working copy)
@@ -61,12 +61,15 @@
 	if(NULL == pcre_regexp)
 		return FAIL;
 
-	if(regexp)
+	if (NULL != regexp)
 	{
 		*regexp = (zbx_regexp_t *)zbx_malloc(NULL, sizeof(zbx_regexp_t));
 		(*regexp)->pcre_regexp = pcre_regexp;
 	}
+	else
+		pcre_free(pcre_regexp);
 
+
 	return SUCCEED;
 }
 
 | 
| Comments | 
| Comment by Andris Zeila [ 2018 Oct 30 ] | 
| The leak happens when validating item preprocessing regsub step during low level discovery. | 
| Comment by Andris Zeila [ 2018 Nov 02 ] | 
| Released in: 
 |