[XviD-devel] Fw: libxvidcore decompression

Dark Sylinc dark_sylinc at yahoo.com.ar
Thu Apr 17 16:13:10 CEST 2008


Hi,
You said it's already fixed, but I saw many important problems in your code:

>#define BUFFER_SIZE (1024*1024*3)
>FILE *fpi;
>long lFileSize = 0;
>unsigned char *gmp4_buffer = 0;

>gmp4_buffer = (unsigned char *)malloc(BUFFER_SIZE);
Later you do:
>gmp4_buffer = (unsigned char *) malloc (lFileSize);

That's a MEMORY LEAK!!! You lose track of the previous memory pointer, thus you won't be able to free it later.
Creating a buffer with "BUFFER_SIZE" is pointless anyway. Remove that line. 

>if(gmp4_buffer==0)
>{
>Msg(TEXT("gmp4_buffer is empty, cannot read from file"));
>}

Wrong!
if (gmp4_buffer==0) then the system failed to allocate the ammount of memory RAM you requested (with malloc...). It has nothing to do with reading the file. (Of course, if you don't have space in memory where to store what you've read, the reading routine will also fail, and possibly crash)

Cheers
Dark Sylinc



      Tarjeta de crédito Yahoo! de Banco Supervielle.
Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar 


More information about the XviD-devel mailing list