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
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;
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)