summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins/syntaxes
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-07-24 01:15:17 -0500
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-19 16:59:33 -0700
commitfd8ac10e935bca1f72bfe0f5735fe8f5c2572229 (patch)
tree78220134f071a1853e3100e141ce252c00a16495 /ldap/servers/plugins/syntaxes
parent7aa393f72369f50974cc8d2932d7878f023c3a42 (diff)
downloadds-fd8ac10e935bca1f72bfe0f5735fe8f5c2572229.tar.gz
ds-fd8ac10e935bca1f72bfe0f5735fe8f5c2572229.tar.xz
ds-fd8ac10e935bca1f72bfe0f5735fe8f5c2572229.zip
Bug 617630 - fix coverify Defect Type: Resource leaks issues CID 12052 - 12093
https://bugzilla.redhat.com/show_bug.cgi?id=617630 Resolves: bug 617630 Bug description: fix coverify Defect Type: Resource leaks issues CID 12064, 12065. description: string_assertion2keys_sub() has been modified to release resources before returning.
Diffstat (limited to 'ldap/servers/plugins/syntaxes')
-rw-r--r--ldap/servers/plugins/syntaxes/string.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 18e7a051..d70ca5b6 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -688,11 +688,15 @@ string_assertion2keys_sub(
int localsublens[3] = {SUBBEGIN, SUBMIDDLE, SUBEND};/* default values */
int maxsublen;
char *comp_buf = NULL;
+ /* altinit|any|final: store alt string from value_normalize_ext if any,
+ * otherwise the original string. And use for the real job */
char *altinit = NULL;
- char *oaltinit = NULL;
char **altany = NULL;
- char **oaltany = NULL;
char *altfinal = NULL;
+ /* oaltinit|any|final: prepared to free altinit|any|final if allocated in
+ * value_normalize_ext */
+ char *oaltinit = NULL;
+ char **oaltany = NULL;
char *oaltfinal = NULL;
int anysize = 0;
@@ -776,7 +780,7 @@ string_assertion2keys_sub(
}
}
if ( nsubs == 0 ) { /* no keys to return */
- return( 0 );
+ goto done;
}
/*
@@ -795,7 +799,6 @@ string_assertion2keys_sub(
substring_comp_keys( ivals, &nsubs, altinit, initiallen, '^', syntax,
comp_buf, substrlens );
}
- slapi_ch_free_string(&oaltinit);
for ( i = 0; altany != NULL && altany[i] != NULL; i++ ) {
len = strlen( altany[i] );
if ( len < substrlens[INDEX_SUBSTRMIDDLE] ) {
@@ -803,18 +806,22 @@ string_assertion2keys_sub(
}
substring_comp_keys( ivals, &nsubs, altany[i], len, 0, syntax,
comp_buf, substrlens );
- slapi_ch_free_string(&oaltany[i]);
}
- slapi_ch_free((void **)&oaltany);
- slapi_ch_free((void **)&altany);
if ( altfinal != NULL ) {
substring_comp_keys( ivals, &nsubs, altfinal, finallen, '$', syntax,
comp_buf, substrlens );
}
- slapi_ch_free_string(&oaltfinal);
(*ivals)[nsubs] = NULL;
- slapi_ch_free_string(&comp_buf);
+done:
+ slapi_ch_free_string(&oaltinit);
+ for ( i = 0; altany != NULL && altany[i] != NULL; i++ ) {
+ slapi_ch_free_string(&oaltany[i]);
+ }
+ slapi_ch_free((void **)&oaltany);
+ slapi_ch_free_string(&oaltfinal);
+ slapi_ch_free((void **)&altany);
+ slapi_ch_free_string(&comp_buf);
return( 0 );
}