Avoid freeing unused memory. Some code clean-up.

Patch provided by David Hoyer.
This commit is contained in:
Jesse Smith 2019-11-04 12:12:44 -04:00
parent ad50c8272e
commit 9bc925d0e9
2 changed files with 9 additions and 14 deletions

View File

@ -4,6 +4,8 @@ sysvinit (2.97) unreleased; urgency=low
Added logsave and readbootlog to list of files git ignores. Added logsave and readbootlog to list of files git ignores.
- Patches provided by Petr Ovtchenkov. - Patches provided by Petr Ovtchenkov.
* Code clean-up and making sure we avoid freeing unused memory.
Patch provided by David Hoyer.
sysvinit (2.96) released; urgency=low sysvinit (2.96) released; urgency=low

View File

@ -513,7 +513,7 @@ int readproc(int do_stat)
if (p->argv0) free(p->argv0); if (p->argv0) free(p->argv0);
if (p->argv1) free(p->argv1); if (p->argv1) free(p->argv1);
if (p->statname) free(p->statname); if (p->statname) free(p->statname);
free(p->pathname); if (p->pathname) free(p->pathname);
free(p); free(p);
} }
plist = NULL; plist = NULL;
@ -562,7 +562,7 @@ int readproc(int do_stat)
if (p->argv0) free(p->argv0); if (p->argv0) free(p->argv0);
if (p->argv1) free(p->argv1); if (p->argv1) free(p->argv1);
if (p->statname) free(p->statname); if (p->statname) free(p->statname);
free(p->pathname); if (p->pathname) free(p->pathname);
free(p); free(p);
continue; continue;
} }
@ -578,13 +578,6 @@ int readproc(int do_stat)
/* Get session, startcode, endcode. */ /* Get session, startcode, endcode. */
startcode = endcode = 0; startcode = endcode = 0;
/*
if (sscanf(q, "%*c %*d %*d %d %*d %*d %*u %*u "
"%*u %*u %*u %*u %*u %*d %*d "
"%*d %*d %*d %*d %*u %*u %*d "
"%*u %lu %lu",
&p->sid, &startcode, &endcode) != 3) {
*/
if (sscanf(q, "%10s %*d %*d %d %*d %*d %*u %*u " if (sscanf(q, "%10s %*d %*d %d %*d %*d %*u %*u "
"%*u %*u %*u %*u %*u %*d %*d " "%*u %*u %*u %*u %*u %*d %*d "
"%*d %*d %*d %*d %*u %*u %*d " "%*d %*d %*d %*d %*u %*u %*d "
@ -624,7 +617,7 @@ int readproc(int do_stat)
if (p->argv0) free(p->argv0); if (p->argv0) free(p->argv0);
if (p->argv1) free(p->argv1); if (p->argv1) free(p->argv1);
if (p->statname) free(p->statname); if (p->statname) free(p->statname);
free(p->pathname); if (p->pathname) free(p->pathname);
free(p); free(p);
continue; continue;
} }
@ -672,7 +665,7 @@ int readproc(int do_stat)
if (p->argv0) free(p->argv0); if (p->argv0) free(p->argv0);
if (p->argv1) free(p->argv1); if (p->argv1) free(p->argv1);
if (p->statname) free(p->statname); if (p->statname) free(p->statname);
free(p->pathname); if (p->pathname) free(p->pathname);
free(p); free(p);
continue; continue;
} }