Diff between 95ea711d0dad1826a75f112ba94823a413db4b89 and b594920572e4a719a745f1487f822fdff5a20709

Changed Files

File Additions Deletions Status
obexd/src/ftp.c +10 -3 modified

Full Patch

diff --git a/obexd/src/ftp.c b/obexd/src/ftp.c
index bd40feb..9ab13c5 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)