Skip to contentSkip to conversation

nfs-utils: Fix memory leak on error in nfs-server-generator

PATCH In review Alice J Mitchell 2 participants 2 messages Aug 1, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs-utils: Fix memory leak on error in nfs-server-generator

Fix the trivial memory leak in the error handling of nfs-server-generator

---
 systemd/nfs-server-generator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
systemd/nfs-server-generator.c +2 -1
index 737f109..eec98fd 100644
@@ -25,6 +25,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <mntent.h>
+#include <alloca.h>
 
 #include "misc.h"
 #include "nfslib.h"
@@ -98,7 +99,7 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	path = malloc(strlen(argv[1]) + sizeof(dirbase) + sizeof(filebase));
+	path = alloca(strlen(argv[1]) + sizeof(dirbase) + sizeof(filebase));
 	if (!path)
 		exit(2);
 	if (export_read(_PATH_EXPORTS, 1) +
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · Alice J Mitchell

Fix the trivial memory leak in the error handling of nfs-server-generator

Committed...

steved.

Quoted 26 lines
---
 systemd/nfs-server-generator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
systemd/nfs-server-generator.c +2 -1
index 737f109..eec98fd 100644
@@ -25,6 +25,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <mntent.h>
+#include <alloca.h>
 
 #include "misc.h"
 #include "nfslib.h"
@@ -98,7 +99,7 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	path = malloc(strlen(argv[1]) + sizeof(dirbase) + sizeof(filebase));
+	path = alloca(strlen(argv[1]) + sizeof(dirbase) + sizeof(filebase));
 	if (!path)
 		exit(2);
 	if (export_read(_PATH_EXPORTS, 1) +