From dcb4042890ea121e29c56eea1dd6c6bcd912e2ba Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 11 Jul 2018 19:54:17 +0200 Subject: ic: Fix memory leak in oe_ei_decode_wstring --- lib/ic/c_src/oe_ei_decode_wstring.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/ic/c_src/oe_ei_decode_wstring.c b/lib/ic/c_src/oe_ei_decode_wstring.c index 66eaf66392..d2a8270291 100644 --- a/lib/ic/c_src/oe_ei_decode_wstring.c +++ b/lib/ic/c_src/oe_ei_decode_wstring.c @@ -78,8 +78,10 @@ int oe_ei_decode_wstring(const char *buf, int *index, CORBA_wchar *p) { /* Allocate temporary string */ tmp_space = (char*) malloc((length + 1)*sizeof(char)); - if ((error_code = ei_decode_string(buf, index, tmp_space)) < 0) - return error_code; + if ((error_code = ei_decode_string(buf, index, tmp_space)) < 0) { + free(tmp_space); + return error_code; + } /* Assign characters to wide characters */ for(tmp = 0; tmp < length; tmp++) @@ -88,7 +90,7 @@ int oe_ei_decode_wstring(const char *buf, int *index, CORBA_wchar *p) { p[tmp] = 0; /* Wide NULL */ /* Free temporary string */ - CORBA_free(tmp_space); + free(tmp_space); } else { /* Allocation counting part */ -- cgit v1.2.3