[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Otavio Salvador otavio at alioth.debian.org
Thu Apr 24 20:09:13 UTC 2008


 libparted/exception.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit abc24c32fc7bca23d9cd2b82b1bcafec6c4b5f21
Author: Otavio Salvador <otavio at ossystems.com.br>
Date:   Thu Apr 24 15:55:47 2008 -0300

    fix memory leak in exception handler
    
    The exception handler wasn't freeing the memory when the allocated
    space wasn't enough to store the error message thus leaving unmanaged
    memory around.

diff --git a/libparted/exception.c b/libparted/exception.c
index d9425a3..c9a50bb 100644
--- a/libparted/exception.c
+++ b/libparted/exception.c
@@ -243,7 +243,7 @@ ped_exception_throw (PedExceptionType ex_type,
 	ex->options = ex_opts;
 
 	while (1) {
-			ex->message = (char*) malloc (size);
+			ex->message = (char*) malloc (size * sizeof (char));
 			if (!ex->message)
 					goto no_memory;
 
@@ -255,6 +255,7 @@ ped_exception_throw (PedExceptionType ex_type,
 					break;
 
 			size += 10;
+			ped_free (ex->message);
 	}
 
 	return do_throw ();



More information about the Parted-commits mailing list