pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files/lib Make allocation errors ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ea01eae4708f
branches:  trunk
changeset: 533398:ea01eae4708f
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Tue Sep 18 15:38:10 2007 +0000

description:
Make allocation errors fatal. Better than leaking memory in the error
case.

diffstat:

 pkgtools/pkg_install/files/lib/iterate.c |  15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diffs (29 lines):

diff -r f3e552eb25c9 -r ea01eae4708f pkgtools/pkg_install/files/lib/iterate.c
--- a/pkgtools/pkg_install/files/lib/iterate.c  Tue Sep 18 14:14:31 2007 +0000
+++ b/pkgtools/pkg_install/files/lib/iterate.c  Tue Sep 18 15:38:10 2007 +0000
@@ -384,20 +384,15 @@
                /* Current package is better, remember it. */
                free(arg->best_current_match);
                free(arg->best_current_match_filtered);
-               if ((arg->best_current_match = strdup(filename)) == NULL) {
-                       arg->best_current_match_filtered = NULL;
-                       free(filtered_filename);
-                       return -1;
-               }
+               if ((arg->best_current_match = strdup(filename)) == NULL)
+                       err(EXIT_FAILURE, "strdup failed");
                if (filtered_filename != NULL)
                        arg->best_current_match_filtered = filtered_filename;
-               else if ((arg->best_current_match_filtered = strdup(active_filename)) == NULL) {
-                       free(arg->best_current_match);
-                       return -1;
-               }
+               else if ((arg->best_current_match_filtered = strdup(active_filename)) == NULL)
+                       err(EXIT_FAILURE, "strdup failed");
                return 0;
        default:
-               return -1;
+               errx(EXIT_FAILURE, "Invalid error from pkg_order");
        }
 }
 



Home | Main Index | Thread Index | Old Index