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

Message ID 1564657141.8625.7.camel@redhat.com
State New
Headers show
Series
  • nfs-utils: Fix memory leak on error in nfs-server-generator
Related show

Commit Message

Alice J Mitchell Aug. 1, 2019, 10:59 a.m. UTC
Fix the trivial memory leak in the error handling of nfs-server-generator

Signed-off-by: Alice J Mitchell <ajmitchell@redhat.com>
---
 systemd/nfs-server-generator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steve Dickson Aug. 1, 2019, 4:20 p.m. UTC | #1
On 8/1/19 6:59 AM, Alice J Mitchell wrote:
> Fix the trivial memory leak in the error handling of nfs-server-generator
> 
> Signed-off-by: Alice J Mitchell <ajmitchell@redhat.com>
Committed... 

steved.
> ---
>  systemd/nfs-server-generator.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
> index 737f109..eec98fd 100644
> --- a/systemd/nfs-server-generator.c
> +++ b/systemd/nfs-server-generator.c
> @@ -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) +
>

Patch
diff mbox series

diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
index 737f109..eec98fd 100644
--- a/systemd/nfs-server-generator.c
+++ b/systemd/nfs-server-generator.c
@@ -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) +