最近项目在运行时出现"Buffer too small"
2014-01-04 01:53
393 查看
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));
相关文章推荐
- How to solve (Buffer too Small".0) problem?
- eclipse运行ssh项目出现"HTTP Status 500 - Unable to instantiate Action"
- 在asp.net2.0项目在vs2005下运行没问题,放到IIS下就出现"服务器应用程序不可用",为什么?在asp.net2.0项目在vs2005下运行没问题,放到IIS下就出现"服务器应用程序不可用",为什么?
- 运行ASP.NET出现的问题:无法直接启动带有"类型输出类型"的项目
- 在visual studio .net调试中出现"试图运行项目时出错:无法启动调试。
- eclipse运行android项目出现"The connection to adb is down, and a severe error has occured."的问题
- eclipse运行android项目出现"The connection to adb is down, and a severe error has occured."的问题
- 运行在Linux系统上的Java程序可能会出现"Too many open files"
- 运行android项目出现"Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE"问题
- VS.NET2005 "试图运行项目时出错:无法启动调试。绑定句柄无效"解决
- VS2005.NET提示"试图运行项目时出错,无法启动调试,绑定句柄无效"解决办法
- 解决eclipse中运行web项目时弹出的"Port 8080 required by Tomcat v7.0 Server at localhost is already in use... "
- 安装JDK出现"Windows Installer程序包有问题,此安装需要的DLL不能运行"解决方法
- Android项目运行时出现错误: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for
- JavaScript在IE下设置innerHTML时出现"未知的运行时错误"
- Xcode 运行项目时候选择模拟器位置处显示"My Mac" 的处理
- eclipse运行ssh项目出现"HTTP Status 500 - Unable to instantiate Action"
- 下载CDT插件后重新打开Eclipse运行cocos2d-x游戏项目报错An internal error occurred during: "Android Library Update".
- VS2005.NET提示"试图运行项目时出错,无法启动调试,绑定句柄无效"解决办法
- java运行出现:Exception in thread "main" java.lang.NOClassDefFoundError:Hello(wrong name:hello/Hello)