Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sysinst Fix some memory leaks in error paths



details:   https://anonhg.NetBSD.org/src/rev/33ebf329717b
branches:  trunk
changeset: 453551:33ebf329717b
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Aug 17 18:03:12 2019 +0000

description:
Fix some memory leaks in error paths

diffstat:

 usr.sbin/sysinst/install.c |  17 ++++++++++-------
 usr.sbin/sysinst/util.c    |   3 ++-
 2 files changed, 12 insertions(+), 8 deletions(-)

diffs (76 lines):

diff -r da92c01dd61e -r 33ebf329717b usr.sbin/sysinst/install.c
--- a/usr.sbin/sysinst/install.c        Sat Aug 17 17:51:19 2019 +0000
+++ b/usr.sbin/sysinst/install.c        Sat Aug 17 18:03:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: install.c,v 1.9 2019/07/23 18:13:40 martin Exp $       */
+/*     $NetBSD: install.c,v 1.10 2019/08/17 18:03:12 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -165,7 +165,7 @@
                if (!md_get_info(&install) ||
                    !md_make_bsd_partitions(&install)) {
                        hit_enter_to_continue(MSG_abort_inst, NULL);
-                       return;
+                       goto error;
                }
 
                /* Last chance ... do you really want to do this? */
@@ -173,7 +173,7 @@
                refresh();
                msg_fmt_display(MSG_lastchance, "%s", pm->diskdev);
                if (!ask_noyes(NULL))
-                       return;
+                       goto error;
 
                /*
                 * Check if we have a secondary partitioning and
@@ -194,19 +194,19 @@
                    make_filesystems(&install) ||
                    make_fstab(&install) != 0 ||
                    md_post_newfs(&install) != 0)
-               return;
+               goto error;
        }
 
        /* Unpack the distribution. */
        process_menu(MENU_distset, &retcode);
        if (retcode == 0)
-               return;
+               goto error;
        if (get_and_unpack_sets(0, MSG_disksetupdone,
            MSG_extractcomplete, MSG_abortinst) != 0)
-               return;
+               goto error;
 
        if (md_post_extract(&install) != 0)
-               return;
+               goto error;
 
        do_configmenu(&install);
 
@@ -217,4 +217,7 @@
        free(install.infos);
 
        hit_enter_to_continue(MSG_instcomplete, NULL);
+
+error:
+       free(install.infos);
 }
diff -r da92c01dd61e -r 33ebf329717b usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Sat Aug 17 17:51:19 2019 +0000
+++ b/usr.sbin/sysinst/util.c   Sat Aug 17 18:03:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.30 2019/08/17 17:51:19 martin Exp $ */
+/*     $NetBSD: util.c,v 1.31 2019/08/17 18:03:12 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -933,6 +933,7 @@
                            1, &dist->name);
                        hit_enter_to_continue(err, NULL);
                        free(err);
+                       free(owd);
                        return SET_RETRY;
                }
 #ifdef SUPPORT_8_3_SOURCE_FILESYSTEM



Home | Main Index | Thread Index | Old Index