最近项目在运行时出现"Buffer too small"
来源:互联网 发布:java跨平台原理 编辑:程序博客网 时间:2024/06/06 07:26
int __cdecl _vsprintf_s_l ( char *string, size_t sizeInBytes, const char *format, _locale_t plocinfo, va_list ap ){ int retvalue = -1; /* validation section */ _VALIDATE_RETURN(format != NULL, EINVAL, -1); _VALIDATE_RETURN(string != NULL && sizeInBytes > 0, EINVAL, -1); retvalue = _vsnprintf_helper(_output_s_l, string, sizeInBytes, format, plocinfo, ap); if (retvalue < 0) { string[0] = 0; _SECURECRT__FILL_STRING(string, sizeInBytes, 1); } if (retvalue == -2) { _VALIDATE_RETURN(("Buffer too small", 0), ERANGE, -1);// 异常弹框处 } if (retvalue >= 0) { _SECURECRT__FILL_STRING(string, sizeInBytes, retvalue + 1); } return retvalue;}
开始以为我程序中的wsprintf和sprintf出的问题,后来上网搜了一下,才发现原来是使用CString时用到Format这个函数,参数直接给字符串数组时,有几率发生这种运行时错误,现先用CString赋值,再作参数,如:
char sz_SysDirPath[MAXBYTE] = "";GetSystemDirectory(sz_SysDirPath,MAXBYTE);CString csSysDirPath = sz_SysDirPath;CString cs_DriverPath;cs_DriverPath.Format("%s\\memory.sys",csSysDirPath.GetBuffer(0));
0 0
- 最近项目在运行时出现"Buffer too small"
- 在运行ocrconfig replace ocrmirror命令时出现PROT-22: Storage too small错误
- buffer too small
- buffer too small
- Buffer is too small
- CString::Format出现的Buffer too small错误
- c++ buffer is too small
- 运行make menucofig 时出现Your display is too small to run Menuconfig! 解决办法
- vc中CString::Format出现的Buffer too small错误(转)
- vc中CString::Format出现的Buffer too small错误(转)
- C中strcpy_s出现“buffer is too small …… ”问题
- char* 转CString CString::Format出现的Buffer too small错误
- str.Format 错误 Buffer too small
- CString.Format报Buffer too small问题
- strcpy_s Buffer is too small 出错根本原因
- xsql---Buffer too small for record data
- CString.Format报Buffer too small问题
- CString.Format报Buffer too small问题
- 解析ASP.NET Mvc开发之EF延迟加载
- Android 高仿QQ 界面滑动效果
- c语言的一处陷阱:
- 设计模式初探-适配器模式
- Linux Trace Toolkit
- 最近项目在运行时出现"Buffer too small"
- 1_简介与学习方法
- IIS6 JQuery 未定义 解决办法
- JDK6和JDK7中的substring()方法
- Win7遇到:应用程序已停止工作,故障模块 ntdll.dll
- cocos2d-x 设置竖屏的方法
- ListAcitivy 的几个adapter 学习过程遇到的异常
- [LeetCode] Interleaving String
- XamarinInstaller.exe闪退问题