Fix valgrind errors
authorVolker Lendecke <vl@samba.org>
Mon, 4 Feb 2008 18:33:56 +0000 (19:33 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 4 Feb 2008 18:41:04 +0000 (19:41 +0100)
We need to keep the names around on the search. Probably a tdb_move would do it
here as well, but RPC is not the fastest thing on earth anyway...

Thanks to Günther for pointing that out to me!

source/passdb/pdb_smbpasswd.c

index 6cf54fbdf66bda3206111b29bd8dd7a97e4e7fc1..70944a9596829746003235c41d6d878d0c832dbe 100644 (file)
@@ -1559,8 +1559,24 @@ static bool smbpasswd_search_next_entry(struct pdb_search *search,
                return false;
        }
 
-       *entry = state->entries[state->current++];
+       entry->idx = state->entries[state->current].idx;
+       entry->rid = state->entries[state->current].rid;
+       entry->acct_flags = state->entries[state->current].acct_flags;
+
+       entry->account_name = talloc_strdup(
+               search->mem_ctx, state->entries[state->current].account_name);
+       entry->fullname = talloc_strdup(
+               search->mem_ctx, state->entries[state->current].fullname);
+       entry->description = talloc_strdup(
+               search->mem_ctx, state->entries[state->current].description);
+
+       if ((entry->account_name == NULL) || (entry->fullname == NULL)
+           || (entry->description == NULL)) {
+               DEBUG(0, ("talloc_strdup failed\n"));
+               return false;
+       }
 
+       state->current += 1;
        return true;
 }