bc9fd4
From ccdd8c803182f5c172580379a56e84a23789cf0d Mon Sep 17 00:00:00 2001
bc9fd4
From: Alice J Mitchell <ajmitchell@redhat.com>
bc9fd4
Date: Mon, 29 Jul 2019 15:49:34 +0100
bc9fd4
Subject: [PATCH] Fix memory leak on error in nfs-server-generator
bc9fd4
bc9fd4
Fix the trivial memory leak in the error handling of nfs-server-generator
bc9fd4
bc9fd4
Resolves: bz1440524
bc9fd4
Signed-off-by: Alice J Mitchell <ajmitchell@redhat.com>
bc9fd4
---
bc9fd4
 systemd/nfs-server-generator.c | 3 ++-
bc9fd4
 1 file changed, 2 insertions(+), 1 deletion(-)
bc9fd4
bc9fd4
diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
bc9fd4
index 737f109..eec98fd 100644
bc9fd4
--- a/systemd/nfs-server-generator.c
bc9fd4
+++ b/systemd/nfs-server-generator.c
bc9fd4
@@ -25,6 +25,7 @@
bc9fd4
 #include <ctype.h>
bc9fd4
 #include <stdio.h>
bc9fd4
 #include <mntent.h>
bc9fd4
+#include <alloca.h>
bc9fd4
 
bc9fd4
 #include "misc.h"
bc9fd4
 #include "nfslib.h"
bc9fd4
@@ -98,7 +99,7 @@ int main(int argc, char *argv[])
bc9fd4
 		exit(1);
bc9fd4
 	}
bc9fd4
 
bc9fd4
-	path = malloc(strlen(argv[1]) + sizeof(dirbase) + sizeof(filebase));
bc9fd4
+	path = alloca(strlen(argv[1]) + sizeof(dirbase) + sizeof(filebase));
bc9fd4
 	if (!path)
bc9fd4
 		exit(2);
bc9fd4
 	if (export_read(_PATH_EXPORTS, 1) +
bc9fd4
-- 
bc9fd4
1.8.3.1
bc9fd4