s3 ldb: Fix vasprintf segfault that has been the source of build machine failures...
authorTim Prouty <tprouty@samba.org>
Sat, 24 Jan 2009 00:09:13 +0000 (16:09 -0800)
committerTim Prouty <tprouty@samba.org>
Sat, 24 Jan 2009 00:18:21 +0000 (16:18 -0800)
The bug was introduced when converting samba3's ldb_search interface
to match samba4:
47951fc5d0085e124666b7667715bba98076820e
f3ecb701335b1129947127d4c45eef970b66875c

source3/lib/ldb/common/ldb.c

index 6e28528dbf358f6f969d7018ddd2295e51d6631f..cef7373c2674526315d2d404983c94b84d225626 100644 (file)
@@ -808,15 +808,18 @@ int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result *
        va_list ap;
        int ret;
 
+       expression = NULL;
        res = NULL;
        *result = NULL;
 
-       va_start(ap, exp_fmt);
-       expression = talloc_vasprintf(mem_ctx, exp_fmt, ap);
-       va_end(ap);
+       if (exp_fmt) {
+               va_start(ap, exp_fmt);
+               expression = talloc_vasprintf(mem_ctx, exp_fmt, ap);
+               va_end(ap);
 
-       if ( ! expression) {
-               return LDB_ERR_OPERATIONS_ERROR;
+               if ( ! expression) {
+                       return LDB_ERR_OPERATIONS_ERROR;
+               }
        }
 
        ret = _ldb_search(ldb, ldb, &res, base, scope, attrs, expression);