]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Put in some explicit null-pointer checks.
authorSimon Tatham <anakin@pobox.com>
Tue, 14 Feb 2017 20:47:16 +0000 (20:47 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 14 Feb 2017 23:25:25 +0000 (23:25 +0000)
I think these were not strictly necessary, since passing a null
pointer to access(2) would have resulted in EINVAL rather than a
segfault. But it's clearer to put them in (and keeps static checkers a
bit happier).

unix/uxstore.c

index a080e294af3778ea19b33ad34b50a9c22e0a9ad5..15801785cbd93106d611a64aaf2a38aea77ba9d4 100644 (file)
@@ -140,11 +140,11 @@ static char *make_filename(int index, const char *subname)
         }
         old_dir3 = dupstr("/.putty");
 
-        if (access(old_dir, F_OK) == 0) {
+        if (old_dir && access(old_dir, F_OK) == 0) {
             ret = old_dir;
             goto out;
         }
-        if (access(old_dir2, F_OK) == 0) {
+        if (old_dir2 && access(old_dir2, F_OK) == 0) {
             ret = old_dir2;
             goto out;
         }