zzllvlv
zzllvlv
采纳率65.7%
2018-02-28 15:56

关于zlib解压报错的问题

5
  • vc
  • stack overflow
  • zlib
已采纳

int main(int argc, char argv[])
{
char SorceBuffer[1024000] = { 0 };
FILE *stream, *stream2;
errno_t err;
err = fopen_s(&stream, "..\1.zip", "r");
//err = fopen_s(&stream, "..\1.zip", "r+b");

if (err != Z_OK)
{
cout << "文件打开失败!/n" << err << endl;
getchar();
return 1;
}
//获取压缩文件的大小

long ucur = ftell(stream);
fseek(stream, 0L, SEEK_END);
long ufileLength = ftell(stream);
fseek(stream, 0, SEEK_SET);
cout << "获取文件长度:" << ucur << "和" << ufileLength << endl;
char uSorceBuffer[1024000] = { 0 };
int i = fread(uSorceBuffer, ufileLength, 1, stream);
fclose(stream);
if (i == -1)
{
cout << "文件读取失败! \n" << err << endl;
getchar();
return 1;
}
fclose(stream);
uLongf uDestBufferLen = 1024000;//此处长度需要足够大以容纳解压缩后数据
char
uDestBuffer = (char*)::calloc((uInt)uDestBufferLen, 1);
err = uncompress((Bytef*)uDestBuffer, (uLongf*)&uDestBufferLen, (Bytef*)uSorceBuffer, (uLong)ufileLength);
if (err != Z_OK)
{
cout << "解压缩失败! \n" << err << endl;
getchar();
return 1;
}

return 0;
}
其中1.zip是通过compress()函数生成的,为什么运行时出现:
0x00403719 处(位于 VC_CompressionTest.exe 中)引发的异常: 0xC00000FD: Stack overflow (参数: 0x00000000, 0x00292000)。这个问题?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • zzllvlv zzllvlv 3年前

    原因找到了,是源码的预编译头有bug,需要对部分预编译代码进行注释,之后就可以用了

    点赞 评论 复制链接分享
  • u010411862 杨敦钦 3年前

为你推荐