]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
vipw: use xalloc.h
authorKarel Zak <kzak@redhat.com>
Mon, 6 Feb 2012 10:22:54 +0000 (11:22 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 6 Feb 2012 10:22:54 +0000 (11:22 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/vipw.c

index 1926db8c815c5be29c108923f0f50070d07f8585..92b42313f3ad524106c453debbe61705c538881b 100644 (file)
@@ -65,6 +65,7 @@
 #include "nls.h"
 #include "setpwnam.h"
 #include "strutils.h"
+#include "xalloc.h"
 
 #ifdef HAVE_LIBSELINUX
 # include <selinux/selinux.h>
@@ -218,7 +219,7 @@ static void pw_edit(int notsetuid)
        char *p, *editor, *tk;
 
        editor = getenv("EDITOR");
-       editor = strdup(editor ? editor : _PATH_VI);
+       editor = xstrdup(editor ? editor : _PATH_VI);
 
        tk = strtok(editor, " \t");
        if (tk && (p = strrchr(tk, '/')) != NULL)
@@ -251,6 +252,8 @@ static void pw_edit(int notsetuid)
        }
        if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0)
                pw_error(editor, 1, 1);
+
+       free(editor);
 }
 
 void pw_error(char *name, int err, int eval)