possible memory leak in libhal_drive_from_udi

Brendan Creane bcreane at yahoo.com
Thu Feb 16 14:07:51 PST 2006


This may be an incorrect way to use libhal (I'm just starting), but it produces a steady memory leak (hal 0.5.3-0, Ubuntu, kernel 2.6.12-10-386): 
 
    while (1) 
    { 
        m_drive = libhal_drive_from_udi (m_halCtx, my_udi); 
        libhal_drive_free(m_drive); 
    } 
 
My intention is to create a persistent hal context and then get information about a drive, then free the drive.  
 
I'm guessing the leak is coming from line 00818 of libhal-storage.c (inside libhal_drive_from_udi): 
    00818     drive = malloc (sizeof (LibHalDrive)); 
 
The complementary free is line 00950: 
    00950     libhal_drive_free (drive); 
 
The libhal_drive_free frees all the strings that "drive" points to, but the "drive" structure itself is (apparently) never freed. 
 
Is this a legitimate problem, and has it been fixed in a later release of libhal? 
 
Thanks for your help, 
 Brendan Creane 




More information about the hal mailing list