may not return uninitialized Completion structure. also do not return nil if directory is empty. this was inspired by bitbucket issue #139 by Mauricio CA https://bitbucket.org/rsc/plan9port/issue/139/bogus-error-message-when-using-control-f but i think the fix on bitbucket will return uninitialized memory. also, it does a bunch of dancing around in acme, which doesn't seem interesting. other opinions? Reference: /n/atom/patch/applied/completenildir Date: Wed Jan 8 13:12:05 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/libcomplete/complete.c Wed Jan 8 13:08:29 2014 +++ /sys/src/libcomplete/complete.c Wed Jan 8 13:08:30 2014 @@ -58,7 +58,7 @@ return nil; n = dirreadall(fd, &dirp); - if(n <= 0){ + if(n < 0){ close(fd); return nil; } @@ -73,10 +73,9 @@ name = malloc(n*sizeof(char*)); mode = malloc(n*sizeof(ulong)); - c = malloc(sizeof(Completion) + len); + c = mallocz(sizeof(Completion) + len, 1); if(name == nil || mode == nil || c == nil) goto Return; - memset(c, 0, sizeof(Completion)); /* find the matches */ len = strlen(s);