Author: delphij
Date: Tue Jul  2 17:34:34 2013
New Revision: 252514
URL: http://svnweb.freebsd.org/changeset/base/252514

Log:
  Plug a memory leak.

Modified:
  head/sbin/swapon/swapon.c

Modified: head/sbin/swapon/swapon.c
==============================================================================
--- head/sbin/swapon/swapon.c   Tue Jul  2 17:17:42 2013        (r252513)
+++ head/sbin/swapon/swapon.c   Tue Jul  2 17:34:34 2013        (r252514)
@@ -491,6 +491,7 @@ swap_on_off_md(const char *name, char *m
                                if (!qflag)
                                        warnx("%s: Device already in use",
                                            vnodefile);
+                               free(vnodefile);
                                return (NULL);
                        }
                        error = run_cmd(&fd, "%s -a -t vnode -n -f %s",
@@ -498,6 +499,7 @@ swap_on_off_md(const char *name, char *m
                        if (error) {
                                warnx("mdconfig (attach) error: file=%s",
                                    vnodefile);
+                               free(vnodefile);
                                return (NULL);
                        }
                        sfd = fdopen(fd, "r");
@@ -537,6 +539,7 @@ swap_on_off_md(const char *name, char *m
                                if (!qflag)
                                        warnx("md%d on %s: Device already "
                                            "in use", mdunit, vnodefile);
+                               free(vnodefile);
                                return (NULL);
                        }
                        error = run_cmd(NULL, "%s -a -t vnode -u %d -f %s",
@@ -544,6 +547,7 @@ swap_on_off_md(const char *name, char *m
                        if (error) {
                                warnx("mdconfig (attach) error: "
                                    "md%d on file=%s", mdunit, vnodefile);
+                               free(vnodefile);
                                return (NULL);
                        }
                }
@@ -557,6 +561,7 @@ swap_on_off_md(const char *name, char *m
                                if (!qflag)
                                        warnx("md on %s: Device not found",
                                            vnodefile);
+                               free(vnodefile);
                                return (NULL);
                        }
                        sfd = fdopen(fd, "r");
@@ -599,6 +604,7 @@ swap_on_off_md(const char *name, char *m
                                if (!qflag)
                                        warnx("md%d on %s: Device not found",
                                            mdunit, vnodefile);
+                               free(vnodefile);
                                return (NULL);
                        }
                }
@@ -622,6 +628,7 @@ err:
                fclose(sfd);
        if (fd != -1)
                close(fd);
+       free(vnodefile);
        return (ret);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to