summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--uisimulator/x11/io.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/uisimulator/x11/io.c b/uisimulator/x11/io.c
index 1e2ebd76c0..17a0c94b70 100644
--- a/uisimulator/x11/io.c
+++ b/uisimulator/x11/io.c
@@ -19,18 +19,24 @@ typedef struct mydir MYDIR;
MYDIR *x11_opendir(char *name)
{
char buffer[256]; /* sufficiently big */
- MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
+ DIR *dir;
if(name[0] == '/') {
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
- my->dir=(DIR *)opendir(buffer);
+ dir=(DIR *)opendir(buffer);
}
else
- my->dir=(DIR *)opendir(name);
-
- my->name = (char *)strdup(name);
+ dir=(DIR *)opendir(name);
+
+ if(dir) {
+ MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
+ my->dir = dir;
+ my->name = (char *)strdup(name);
- return my;
+ return my;
+ }
+ /* failed open, return NULL */
+ return (MYDIR *)0;
}
struct x11_dirent *x11_readdir(MYDIR *dir)