dphase - Stabilization
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 22 Aug 2019 15:35:32 +0000 (08:35 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 22 Aug 2019 15:35:32 +0000 (08:35 -0700)
* Fix a memory leak in scanit()

* When fork()/forkpty() fails, provide a reason in log 00.

usr.bin/dsynth/build.c
usr.bin/dsynth/repo.c

index 12ce320..dfa57df 100644 (file)
@@ -1762,8 +1762,8 @@ dophase(worker_t *work, wmsg_t *wmsg, int wdog, int phaseid, const char *phase)
        fcntl(MasterPtyFd, F_SETFL, O_NONBLOCK);
 
        if (pid < 0) {
        fcntl(MasterPtyFd, F_SETFL, O_NONBLOCK);
 
        if (pid < 0) {
-               dlog(DLOG_ALL, "[%03d] %s Fork Failed\n",
-                    work->index, pkg->logfile);
+               dlog(DLOG_ALL, "[%03d] %s Fork Failed: %s\n",
+                    work->index, pkg->logfile, strerror(errno));
                ++work->accum_error;
                return;
        }
                ++work->accum_error;
                return;
        }
index 0f28f8a..5baf6d0 100644 (file)
@@ -242,7 +242,6 @@ scanit(const char *path, const char *subpath,
                                        scanit(npath, den->d_name,
                                               countp, list_tailp);
                                }
                                        scanit(npath, den->d_name,
                                               countp, list_tailp);
                                }
-                               free(npath);
                        } else if (S_ISREG(st.st_mode)) {
                                item = calloc(1, sizeof(*item));
                                if (subpath) {
                        } else if (S_ISREG(st.st_mode)) {
                                item = calloc(1, sizeof(*item));
                                if (subpath) {
@@ -255,9 +254,8 @@ scanit(const char *path, const char *subpath,
                                *list_tailp = &item->next;
                                ++*countp;
                                ddprintf(0, "scan   %s\n", item->spath);
                                *list_tailp = &item->next;
                                ++*countp;
                                ddprintf(0, "scan   %s\n", item->spath);
-                       } else {
-                               free(npath);
                        }
                        }
+                       free(npath);
                }
                closedir(dir);
        }
                }
                closedir(dir);
        }