summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-08-20 13:18:06 -0700
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-20 13:18:06 -0700
commit2619204d067594cd9bf9371e95d8f9a41fbd9c42 (patch)
treea39e91302975890b3b8eb559f7d625b2879e712f
parent26780f3c132dc5af43324e9ade5c5dc25838d80f (diff)
downloadds-2619204d067594cd9bf9371e95d8f9a41fbd9c42.tar.gz
ds-2619204d067594cd9bf9371e95d8f9a41fbd9c42.tar.xz
ds-2619204d067594cd9bf9371e95d8f9a41fbd9c42.zip
Bug 614511 - fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891
https://bugzilla.redhat.com/show_bug.cgi?id=614511 Resolves: bug 614511 Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11846 - 11891 description: Catch possible NULL pointer in collation_indexer_create(). coverity ID: 11873
-rw-r--r--ldap/servers/plugins/collation/collate.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/ldap/servers/plugins/collation/collate.c b/ldap/servers/plugins/collation/collate.c
index 0314469d..be2e3720 100644
--- a/ldap/servers/plugins/collation/collate.c
+++ b/ldap/servers/plugins/collation/collate.c
@@ -426,6 +426,9 @@ collation_indexer_create (const char* oid)
indexer_t* ix = NULL;
const coll_id_t** id = collation_id;
char* locale = NULL; /* NULL == default locale */
+ UCollator* coll = NULL;
+ collation_indexer_t* etc = NULL;
+
if (id) for (; *id; ++id) {
if (!strcasecmp (oid, (*id)->oid)) {
const coll_profile_t* profile = (*id)->profile;
@@ -444,7 +447,7 @@ collation_indexer_create (const char* oid)
profile->variant);
}
if (err == U_ZERO_ERROR) {
- UCollator* coll = ucol_open(locale, &err);
+ coll = ucol_open(locale, &err);
/*
* If we found exactly the right collator for this locale,
* or if we found a fallback one, or if we are happy with
@@ -452,8 +455,7 @@ collation_indexer_create (const char* oid)
*/
if (err == U_ZERO_ERROR || err == U_USING_FALLBACK_WARNING ||
(err == U_USING_DEFAULT_WARNING && is_default)) {
- collation_indexer_t* etc = (collation_indexer_t*)
- slapi_ch_calloc (1, sizeof (collation_indexer_t));
+ etc = (collation_indexer_t*) slapi_ch_calloc (1, sizeof (collation_indexer_t));
ix = (indexer_t*) slapi_ch_calloc (1, sizeof (indexer_t));
ucol_setAttribute (coll, UCOL_STRENGTH, profile->strength, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
@@ -475,6 +477,11 @@ collation_indexer_create (const char* oid)
break; /* found the 'official' id */
}
}
+ if (!*id) {
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
+ goto error;
+ }
+
ix->ix_etc = etc;
ix->ix_oid = (*id)->oid;
ix->ix_index = collation_index;
@@ -500,6 +507,15 @@ collation_indexer_create (const char* oid)
break; /* failed to create the specified collator */
}
}
+ goto done;
+error:
+ slapi_ch_free((void **)&etc);
+ slapi_ch_free((void **)&ix);
+ if (coll) {
+ ucol_close (coll);
+ coll = NULL;
+ }
+done:
if (locale) {
PR_smprintf_free(locale);
locale = NULL;