gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 6c6c6dd 2/3: Fix memory size allocation in lib


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 6c6c6dd 2/3: Fix memory size allocation in lib/checkset.c
Date: Mon, 25 Jul 2016 00:08:33 +0000 (UTC)

branch: master
commit 6c6c6ddec4c8e765a6dcb9a5a916f06df03ec587
Author: Vladimir Markelov <address@hidden>
Commit: Vladimir Markelov <address@hidden>

    Fix memory size allocation in lib/checkset.c
    
    Allocated for a new string memory should be long enough to store the
    original data and ending '\0' character. The patch increases allocated
    memory size by one character for the end-of-string character.
    This fixed the bug #48611
---
 lib/checkset.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/checkset.c b/lib/checkset.c
index 1e089ba..bc32a65 100644
--- a/lib/checkset.c
+++ b/lib/checkset.c
@@ -845,9 +845,9 @@ gal_checkset_not_dir_part(char *input)
   /* Get the length of the notdir name: */
   l=strlen(tmp);
   errno=0;
-  out=malloc(l*sizeof *out);
+  out=malloc((l+1)*sizeof *out);
   if(out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for notdir", l*sizeof *out);
+    error(EXIT_FAILURE, errno, "%lu bytes for notdir", (l+1)*sizeof *out);
 
   strcpy(out, tmp);
   return out;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]