From: Keith Packard Date: Mon, 18 May 2009 05:43:34 +0000 (-0700) Subject: scandir returns -1 on error X-Git-Tag: 0.4~5 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=33221277690e6ee30387c506c3f2b8237ed48efd scandir returns -1 on error In which case, the namelist is invalid, so don't look at it, and don't free it. Signed-off-by: Keith Packard --- diff --git a/aoview/aoview_dev.c b/aoview/aoview_dev.c index a326ad73..33f7f8ec 100644 --- a/aoview/aoview_dev.c +++ b/aoview/aoview_dev.c @@ -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;