Rewrite the tail of nsdb_list_find_entries_s() in bfields-normal form to ensure "tmp" is freed if the return value is not FEDFS_OK.
Fixes: b82f3ba222b51fe607a0da34a1158425f55bde90 Signed-off-by: Chuck Lever <[email protected]> --- src/libnsdb/fileserver.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c index c3a0e29..087c846 100644 --- a/src/libnsdb/fileserver.c +++ b/src/libnsdb/fileserver.c @@ -1765,17 +1765,21 @@ nsdb_list_find_entries_s(nsdb_t host, const char *nce, char ***fsns) } } - if (retval == FEDFS_OK) { - if (tmp[0] == NULL) { - xlog(D_CALL, "%s: No FSN entries under %s", - __func__, nce); - retval = FEDFS_ERR_NSDB_NOFSN; - } else { - xlog(D_CALL, "%s: returning fsn list", __func__); - *fsns = tmp; - } - } else + if (retval != FEDFS_OK) { nsdb_free_string_array(tmp); + goto out; + } + + if (tmp[0] == NULL) { + xlog(D_CALL, "%s: No FSN entries under %s", + __func__, nce); + nsdb_free_string_array(tmp); + retval = FEDFS_ERR_NSDB_NOFSN; + goto out; + } + + xlog(D_CALL, "%s: returning fsn list", __func__); + *fsns = tmp; out: ldap_msgfree(response); _______________________________________________ fedfs-utils-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/fedfs-utils-devel
