scandir returns -1 on error
authorKeith Packard <keithp@keithp.com>
Mon, 18 May 2009 05:43:34 +0000 (22:43 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 18 May 2009 05:43:34 +0000 (22:43 -0700)
In which case, the namelist is invalid, so don't look at it, and don't free
it.

Signed-off-by: Keith Packard <keithp@keithp.com>
aoview/aoview_dev.c

index a326ad73defab28cd0a040716e8806e05062743b..33f7f8ecde929b20b602ffa0f07e7b1a8fe966a1 100644 (file)
@@ -91,7 +91,7 @@ usb_tty(char *sys)
                                       dir_filter_tty,
                                       alphasort);
                        free(endpoint_full);
-                       if (ntty) {
+                       if (ntty > 0) {
                                tty = aoview_fullname("/dev", namelist[0]->d_name + 4);
                                free(namelist);
                                return tty;