From b594920572e4a719a745f1487f822fdff5a20709 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 3 Apr 2009 13:43:54 -0300 Subject: [PATCH] obexd: Fix null pointer passed as an argument to a 'nonnull' parameter. --- obexd/src/ftp.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/obexd/src/ftp.c b/obexd/src/ftp.c index bd40feba2..9ab13c5cd 100644 --- a/obexd/src/ftp.c +++ b/obexd/src/ftp.c @@ -124,13 +124,16 @@ static gboolean folder_listing(struct obex_session *os, guint32 *size) if (lstat(os->current_folder, &dstat) < 0) { error("lstat: %s(%d)", strerror(errno), errno); - g_string_free(listing, TRUE); - return FALSE; + goto failed; } dp = opendir(os->current_folder); + if (dp == NULL) { + error("opendir: failed to access %s", os->current_folder); + goto failed; + } - while (dp && (ep = readdir(dp))) { + while ((ep = readdir(dp))) { gchar *name; gchar *fullname; gchar *line; @@ -174,6 +177,10 @@ static gboolean folder_listing(struct obex_session *os, guint32 *size) os->buf = (guint8*) g_string_free(listing, FALSE); return TRUE; + +failed: + g_string_free(listing, TRUE); + return FALSE; } static gboolean get_capability(struct obex_session *os, guint32 *size) -- 2.47.3