Bugs item #442800, was opened at 2001-07-19 09:30
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=111050&aid=442800&group_id=11050

Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Malcolm Rodgers (mowie_x)
>Assigned to: Zdenek Kabelac (kabi)
Summary: More mem leaks detected avifile0.6 

Initial Comment:
Hi,

I've detected some more memory leaks with mpatrol in
Avifile 0.6 (release version).



Here are the locations:

MEMORY LEAK #1
==============================
  0x0884A63C (57600 bytes) {operator new[]:16030:0}
[5126|EncodeFrame__12VideoEncoderP6CImagePcPiN23|/avifile-0.6/plugins/libwin32/videocodec/VideoEncoder.cpp|175]
        0x4006B819
EncodeFrame__12VideoEncoderP6CImagePcPiN23+409 at
/avifile-0.6/plugins/libwin32/videocodec/VideoEncoder.cpp:175
        
This means there is a leak on line 175 of
VideoEncoder.cpp.  Here is that line
to the end of the function

    if(m_prev==0)m_prev=new
char[codec->CompressGetSize(m_bh, m_obh)];
            memcpy(m_prev, dest, m_obh->biSizeImage);
            m_prevbh=*m_bh;
        }
        m_iFrameNum++;
        *size=m_obh->biSizeImage;
        return result;
}
This leak only occurs once.


MEMORY LEAK #2
=======================
  0x080D3D08 (40 bytes) {operator new[]:13674:0}
[5126|__12VideoEncoderRC9CodecInfoiRC16BITMAPINFOHEADER|/avifile-0.6/plugins/libwin32/videocodec/VideoEncoder.cpp|71]
        0x4006B1AC
__12VideoEncoderRC9CodecInfoiRC16BITMAPINFOHEADER+428
at
/avifile-0.6/plugins/libwin32/videocodec/VideoEncoder.cpp:71
        
This means there is a leak on line 71 of
VideoEncoder.cpp.  Here is
that line:

m_obh=(BITMAPINFOHEADER*)new char[h];
        memset(m_obh, 0, h);
        m_obh->biSize=h;

MEMORY LEAK #3
=========================================
 0x080CA8D0 (24 bytes) {malloc:13446:0}
[5126|HeapAlloc|/avifile-0.6/plugins/libwin32/loader/ext.c|63]
        0x4005C290 HeapAlloc+64 at
/avifile-0.6/plugins/libwin32/loader/ext.c:63
        0x4005E32C fixup_imports+300 at
/avifile-0.6/plugins/libwin32/loader/pe_image.c:276
        0x4005F517 PE_CreateModule+903 at
/avifile-0.6/plugins/libwin32/loader/pe_image.c:812
        0x4005F5FA PE_LoadLibraryExA+186 at
/avifile-0.6/plugins/libwin32/loader/pe_image.c:852
        0x4005D7BD MODULE_LoadLibraryExA+77 at
/avifile-0.6/plugins/libwin32/loader/module.c:331
        0x4005D6D1 LoadLibraryExA+65 at
/avifile-0.6/plugins/libwin32/loader/module.c:293
        0x4005D882 LoadLibraryA+34 at
/avifile-0.6/plugins/libwin32/loader/module.c:362
        0x4006CD16
__6ModuleGt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0R17VideoCodecControl+182
at
/avifile-0.6/plugins/libwin32/videocodec/Module.cpp:27
        0x4006D8B2
Create__17VideoCodecControliRC9CodecInfoQ26Module4Mode+386
at
/avifile-0.6/plugins/libwin32/videocodec/VideoCodec.cpp:31
        0x4006B0F3
__12VideoEncoderRC9CodecInfoiRC16BITMAPINFOHEADER+243
at
/avifile-0.6/plugins/libwin32/videocodec/VideoEncoder.cpp:66

This one is a little trickier, it says that memory
created by HeapAlloc, causes a leak. Heap Alloc is
called by pe_image.c
here:
  wm->deps  = HeapAlloc( GetProcessHeap(), 0,
i*sizeof(WINE_MODREF *) );

Not sure on this one, but it's 24 byte in size, if that
helps

MEMORY LEAK #4
=============================================

 0x081F3C2C (5 bytes) {malloc:1985:0}
[1024|insert_handle|
/avifile-0.6/plugins/libwin32/loader/registry.c|206]
        0x40060E0B insert_handle+123 at
/avifile-0.6/plugins/libwin32/loader/registry.c:206
        0x400610F5 init_registry+85 at
/avifile-0.6/plugins/libwin32/loader/registry.c:270
        0x40061236 RegOpenKeyExA+54 at
/avifile-0.6/plugins/libwin32/loader/registry.c:300
        0x4006CE82
__6ModuleGt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0R17VideoCodecControl+546
at
/avifile-0.6/plugins/libwin32/videocodec/Module.cpp:40
        0x4006D8B2
Create__17VideoCodecControliRC9CodecInfoQ26Module4Mode+386
at
/avifile-0.6/plugins/libwin32/videocodec/VideoCodec.cpp:31
        0x4006B0F3
__12VideoEncoderRC9CodecInfoiRC16BITMAPINFOHEADER+243
at
/avifile-0.6/plugins/libwin32/videocodec/VideoEncoder.cpp:66

Here is line 206 onward of registry.c 

t->name=(char*)malloc(strlen(name)+1);
        strcpy(t->name, name);
        t->handle=handle;
        head=t;
        return t;
} 

MEMORY LEAK #5
================================

I'm also reporting a memory leak from line 195 of that
same method in registry.c

0x081F3C1C (16 bytes) {malloc:1980:0}
[1024|insert_handle|
/avifile-0.6/plugins/libwin32/loader/registry.c|195]
        0x40060DAD insert_handle+29 at
/avifile-0.6/plugins/libwin32/loader/registry.c:195
        0x400610F5 init_registry+85 at
/avifile-0.6/plugins/libwin32/loader/registry.c:270
        
which is this line:
t=(reg_handle_t*)malloc(sizeof(reg_handle_t));

I think what it's saying is that the memory created by
both these calls:
static void init_registry()
{
        printf("Initializing registry\n");
        open_registry();
        insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
        insert_handle(HKEY_CURRENT_USER, "HKCU");
}

is not being freed up.


MEMORY LEAK #6 (?)
=================================
In registry.c, these areas are also being reported as
leaks:


static void create_registry(){
    if(regs)
    {
        printf("Logic error: create_registry() called with
existing registry\n");
        save_registry();
        return;
    }   
    regs=(struct reg_value*)malloc(3*sizeof(struct
reg_value));           <-=== here
    regs[0].type=regs[1].type=DIR;
   
regs[0].name=(char*)malloc(5);                                      
<-==== here
    strcpy(regs[0].name, "HKLM");
   
regs[1].name=(char*)malloc(5);                                     
<-===== here
    strcpy(regs[1].name, "HKCU");
    regs[0].value=regs[1].value=NULL;
    regs[0].len=regs[1].len=0;
    reg_size=2;
    save_registry();
}

MEMORY LEAK #7
============================================
This one occurs a lot, so I hope it can be fixed =)
It's also in registry.c

static void open_registry()
{
        int fd;
        int i;
        int len;
         struct passwd* pwent;
         char* pathname;
        if(regs)
        {
                printf("Multiple open_registry(>\n");
                return;
        }
        pwent=getpwuid(getuid());
       
pathname=(char*)malloc(strlen(pwent->pw_dir)+20);
        strcpy(pathname, pwent->pw_dir);

The leak is in the call to pwent=getpwuid(getuid());

Here is the trace

 0x081F3B6C (128 bytes) {calloc:1896:0}
[1024|_dl_check_map_versions|/export/home/chmou/rpm/BUILD/glibc-2.2.2/elf/dl-version.c|286]
        0x4000E98E _dl_check_map_versions+478 at
/export/home/chmou/rpm/BUILD/glibc-2.2.2/elf/dl-version.c:286
        0x403551D9 getutmp+1609
        0x4000D839 _dl_catch_error+233 at
/export/home/chmou/rpm/BUILD/glibc-2.2.2/elf/dl-error.c:149
        0x403552BF _dl_open+111
        0x40355FD2 _dl_mcount_wrapper+818
        0x4000D839 _dl_catch_error+233 at
/export/home/chmou/rpm/BUILD/glibc-2.2.2/elf/dl-error.c:149
        0x40355E6C _dl_mcount_wrapper+460
        0x4033846F __nss_configure_lookup+1455
        0x40338D79 __nss_configure_lookup+3769
        0x40339DD7 __nss_passwd_lookup+55
        0x402FDCF5 getpwuid_r+277
        0x402FD648 getpwuid+104
        0x4006071A open_registry+74 at
/avifile-0.6/plugins/libwin32/loader/registry.c:81
        0x400610CA init_registry+42 at
/avifile-0.6/plugins/libwin32/loader/registry.c:268



----------------------------------------------------------------------

>Comment By: Zdenek Kabelac (kabi)
Date: 2001-11-27 13:10

Message:
Logged In: YES 
user_id=15161

if you are still able to replicate these
leaks with current code let me know
(leaks in libc are not interesting)

----------------------------------------------------------------------

Comment By: Zdenek Kabelac (kabi)
Date: 2001-07-23 09:42

Message:
Logged In: YES 
user_id=15161

Leak #1, #2 -  most probably fixed by current (01/07/23) CVS
update

Leaks in Registry - getpw?? function returns pointer but
this pointer can't be made free.

Leak with initialization - will require some thinking
but in general - these functions should be called just
once during for the whole lifetime of program - so they
are not considered to be that much important



----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=111050&aid=442800&group_id=11050

_______________________________________________
Avifile mailing list
[EMAIL PROTECTED]
http://prak.org/mailman/listinfo/avifile

Reply via email to