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

David Cantrell dcantrell-guest at alioth.debian.org
Thu Aug 9 15:32:19 UTC 2007


 libparted/arch/linux.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 080d3e707879b5c42dc271915c8896eabf7ec711
Author: David Cantrell <dcantrel at mortise.boston.redhat.com>
Date:   Wed Aug 8 18:04:00 2007 -0400

    Sanity check for dev, safety checks on diobuf.
    
    Make sure diobuf is NULL before we begin and make sure it isn't NULL when
    we try to free it.  Throw an exception if dev is NULL and we enter this
    function.
    (cherry picked from commit be2ace6e8d381fb836647234ac65d34a4a547e31)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4a27dd1..f1f6aaa 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1446,8 +1446,9 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start,
 {
         LinuxSpecific*          arch_specific = LINUX_SPECIFIC (dev);
         PedExceptionOption      ex_status;
-        void*                   diobuf;
+        void*                   diobuf = NULL;
 
+        PED_ASSERT (dev != NULL, return 0);
         PED_ASSERT (dev->sector_size % PED_SECTOR_SIZE_DEFAULT == 0, return 0);
 
         if (_get_linux_version() < KERNEL_VERSION (2,6,0)) {
@@ -1528,7 +1529,9 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start,
                                 break;
                 }
         }
-        free(diobuf);
+
+        if (diobuf)
+                free(diobuf);
 
         return 1;
 }



More information about the Parted-commits mailing list