我自己找的问题是sprintf函数,类型和长度都不能错,否则就会报错,报错还不是立马报错,如果类型和长度弄错,内存会异常,后面的代码执行才会内存泄露。
char str3[80];
sprintf(str3, "%d%s got_picture:%d decode_error_num %d", cam_no, " Decode Error", got_picture, decode_error_num);
网上一种解决方法:https://blog.csdn.net/FocusOnACE/article/details/883918
Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
摘要:
经过查询编译器和出错说明,发现了编译器的这一新特性,并修正了代码隐患:
//someheadefile.h
typedef struct tarSomeMessagePack
{
char moibleNumber[20];
....
}SomeMessagePac