]> git.sur5r.net Git - openldap/commitdiff
don't leak in case of error
authorPierangelo Masarati <ando@openldap.org>
Thu, 13 Sep 2007 18:47:36 +0000 (18:47 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 13 Sep 2007 18:47:36 +0000 (18:47 +0000)
servers/slapd/back-meta/config.c

index 1ebeca0ef49f26904d30f1c2a9f4c45a3cec6e6a..c29712e59c038b645601265ee91adb485e6f56cf 100644 (file)
@@ -195,6 +195,7 @@ meta_back_db_config(
                }
 
                for ( c = 0; uris[ c ] != NULL; c++ ) {
+                       char *tmpuri = NULL;
 
                        /*
                         * uri MUST be legal!
@@ -207,6 +208,7 @@ meta_back_db_config(
                "%s: line %d: unable to parse URI #%d"
                " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
                                        fname, lineno, c );
+                               ldap_charray_free( uris );
                                return 1;
                        }
 
@@ -220,6 +222,8 @@ meta_back_db_config(
                        "%s: line %d: missing <naming context> "
                        " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
                                                fname, lineno, 0 );
+                                       ldap_free_urllist( ludp );
+                                       ldap_charray_free( uris );
                                        return 1;
                                }
 
@@ -233,6 +237,8 @@ meta_back_db_config(
                                        Debug( LDAP_DEBUG_ANY, "%s: line %d: "
                                                "target \"%s\" DN is invalid\n",
                                                fname, lineno, argv[ 1 ] );
+                                       ldap_free_urllist( ludp );
+                                       ldap_charray_free( uris );
                                        return( 1 );
                                }
 
@@ -252,6 +258,8 @@ meta_back_db_config(
                                        Debug( LDAP_DEBUG_ANY, "%s: line %d: "
                                                "invalid scope for target \"%s\"\n",
                                                fname, lineno, argv[ 1 ] );
+                                       ldap_free_urllist( ludp );
+                                       ldap_charray_free( uris );
                                        return( 1 );
                                }
 
@@ -262,14 +270,23 @@ meta_back_db_config(
                                                "multiple URIs must have "
                                                "no DN part\n",
                                                fname, lineno, 0 );
+                                       ldap_free_urllist( ludp );
+                                       ldap_charray_free( uris );
                                        return( 1 );
 
                                }
                        }
 
-                       ldap_memfree( uris[ c ] );
-                       uris[ c ] = ldap_url_list2urls( ludp );
+                       tmpuri = ldap_url_list2urls( ludp );
                        ldap_free_urllist( ludp );
+                       if ( tmpuri == NULL ) {
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: no memory?\n",
+                                       fname, lineno, 0 );
+                               ldap_charray_free( uris );
+                               return( 1 );
+                       }
+                       ldap_memfree( uris[ c ] );
+                       uris[ c ] = tmpuri;
                }
 
                mt->mt_uri = ldap_charray2str( uris, " " );