[Gambas-user] error calling external function but not when debugging

Benoit Minisini gambas at ...1...
Thu Dec 18 02:06:09 CET 2008


On lundi 15 décembre 2008, je ber lo wrote:
> hello, I'm using gambas 2.8 on debian and I'm getting different result when
> debugging code ( the result is a md5 hash string (32 characters)) but no
> when executing in a normal way. The error is
>
> Failed to set text from markup due to error parsing markup: Error on line 1
> char 10: Invalid UTF-8 encoded text - not valid '�$R
> ���\u0002}60b725f10c9c85c70d97880dfe8191b3'
>
> The correct result is string 60b725f10c9c85c70d97880dfe8191b3
>
> sometimes I get the following message too.   *** glibc detected ***
> dinamic: double free or corruption (out): 0x08894530 ***
>
>
> I declare the function
>
> EXTERN md5file(filename AS String, resultado AS Pointer) AS Pointer IN
> "mimd5sum"
>
> I call the function with
>
> DIM cas AS Pointer
> DIM cas2 AS Pointer
> DIM cad AS String
>
> cas = Alloc(33)
> cas2 = md5file("/prueba.txt", cas)
> cad = StrPtr(cas2)
> Message(cad)
> Free(cas)
>
>
> and the function in laguage C is:
>
> void miMDPrint (MD5_CTX *mdContext, char* resultado)
> {
>   int i;
>
>   char cadtemporal[3]="";
>
>   for (i = 0; i < 16; i++) {
>     sprintf (cadtemporal, "%02x", mdContext->digest[i]);
>     strcat(resultado, cadtemporal);
>   }
>   //strcat(resultado,"");
>
>
> }
>
>
> char* md5file (char* filename,char* resultado)
> {
>
>   FILE *inFile = fopen (filename, "rb");
>   MD5_CTX mdContext;
>   int bytes;
>   unsigned char data[1024];
>
>   if (inFile == NULL) {
>     //printf ("%s can't be opened.\n", filename);
>     return NULL;
>   }
>
>   MD5Init (&mdContext);
>   while ((bytes = fread (data, 1, 1024, inFile)) != 0)
>     MD5Update (&mdContext, data, bytes);
>   MD5Final (&mdContext);
>   miMDPrint (&mdContext,resultado);
>   fclose (inFile);
>
>   return resultado;
>
> }
>
> Any idea about this problem is welcome.
>
> Regards.

Please send your project, the library, and the needed file data, and explain 
exactly what should be done to reproduce the bug. 

Regards,

-- 
Benoit Minisini




More information about the User mailing list