Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Program:my.exe
debug error File i386\chkesp.c
Line 42
The valueof ESP was not properly saved across fucntion call.This is usally a result of calling a fucntion declared with one calling convention with a function pointer
declared witha declared calling convention..

In C/C++ settings it is _cdecl convention.

the code is which i am coverting bmp to png format

C#
char *inBuffer = new char[inStreamSize];

        uncompressedBufferSize = inStreamSize*40;
        unCompressedBuffer = new char[uncompressedBufferSize];

        inFile.read (inBuffer, inStreamSize);
        //inStreamSize = inFile.gcount();

        zs = new z_stream;
        zs->next_in   = (unsigned char *)inBuffer;  //point to beginning of compressed file
        zs->avail_in  = inFile.gcount();                   //specify the size of the compressed file
        zs->next_out  = (unsigned char *)unCompressedBuffer;  //point to where the uncompressed file will be
        zs->avail_out = uncompressedBufferSize;   //specify size of buffer to hold uncompressed file
        zs->zalloc    = (alloc_func)0;
        zs->zfree     = (free_func)0;
        zs->data_type = Z_BINARY;

        ret = inflateInit(zs);



        ret = inflate(zs, Z_FINISH);
        if(ret != Z_OK && ret != Z_STREAM_END)
        {
            AfxMessageBox("Failed to decompress file");
             inFile.close();
             outFile.close();
            return TRUE;
        }

        ret = inflateEnd (zs);


        if(ret == Z_OK)
        {
            outFile.write (unCompressedBuffer, zs->total_out);
            m_ctrlFileProgress.StepIt();
            CreateBMPFiles(unCompressedBuffer, zs->total_out);
            m_ctrlFileProgress.StepIt();
        //  m_ctrlFileProgress.StepIt();
            CreateLogFile(unCompressedBuffer);
            m_ctrlFileProgress.StepIt();

        }
//cleanup:
         inFile.close();
             outFile.close();

        delete [] zs;
        delete[] unCompressedBuffer;
        delete[] inBuffer;


    }
    m_ctrlFileProgress.SetPos(4);
    SetDlgItemText(IDC_PROGRESS_TEXT, "1 File Converted");
    AfxMessageBox("Decompression Complete");

    return TRUE;
}

after this the error occurs.
Posted
Updated 24-Apr-12 18:52pm
v3
Comments
Sergey Alexandrovich Kryukov 25-Apr-12 0:49am    
What is "debug error"?
--SA

can you identify the line where the error occurs?
 
Share this answer
 
Comments
JOYKAIGA1 26-Apr-12 0:29am    
Message displays correct like "Decompression Complete",after that come out of this loop and error message displays

Program:my.exe
debug error File i386\chkesp.c
Line 42
The valueof ESP was not properly saved across fucntion call.This is usally a result of calling a fucntion declared with one calling convention with a function pointer
declared witha declared calling convention..
JOYKAIGA1 26-Apr-12 0:30am    
this is what displays in call stack


1023325A push edx
1023325B push ebx
1023325C push esi
1023325D push edi
1023325E push offset string "The value of ESP was not properl"... (10258b28)
10233263 push offset string "" (10256788)
10233268 push 2Ah
1023326A push offset string "i386\\chkesp.c" (10258b18)
1023326F push 1
10233271 call _CrtDbgReport (10214eb0)
10233276 add esp,14h
10233279 cmp eax,1
1023327C jne __chkesp+2Fh (1023327f)
1023327E int 3
1023327F pop edi
10233280 pop esi
10233281 pop ebx
10233282 pop edx
10233283 pop eax
10233284 mov esp,ebp
10233286 pop ebp
10233287 ret
10233288 push esi
10233289 inc ebx
1023328A xor dword ptr [eax],esi
1023328C pop eax
1023328D inc ebx
1023328E xor byte ptr [eax],dh
__except_handler2:
10233290 push ebp
10233291 mov ebp,esp
10233293 sub esp,8
10233296 push ebx
10233297 push esi
10233298 push edi
10233299 push ebp.
as the error message says, this usually happens when you call an external library using the wrong calling convention.

i don't see anything obviously wrong with the code you've shown here. double-check the function declarations for any DLLs you're using.
 
Share this answer
 
Comments
JOYKAIGA1 26-Apr-12 9:11am    
Will zlib.dll makes difference in this which iam using 1.4 version here and it should be compatible.is it true ?confirm. Other than zlib.dll i am not using any DLL.
Chris Losinger 26-Apr-12 9:29am    
how are you #including the zLib header?
JOYKAIGA1 26-Apr-12 9:38am    
I am adding in external dependencies zlib files zlib.h file.

2) in vc6.0 settings->links>library/modules options ->i am adding zlib.lib
Chris Losinger 26-Apr-12 9:40am    
when you #include "zlib.h", are you doing this:


#ifdef __cplusplus
extern "C" {
#endif
#include "zlib.h"
#ifdef __cplusplus
}
#endif


?
JOYKAIGA1 26-Apr-12 9:49am    
i added include 'zlib.h' in header file. also #ifdef __cplusplus
extern "C" {
#endif
.still error occurs .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900