0x5F2DEB12(msvcr110.dll)中有未经处理的异常
0x5F2DEB12(msvcr110.dll)中有未经处理的异常:0xC0000005:读取位置***时发生访问冲突。写了一个处理数据的代码,对同一个数据文件进行处理,大概率(10次有7、8次)出现这个错误,小概率(10次里有2、3次)能出正确结果。
不明白是不是程序有问题。如果有问题为什么对同一个文件进行处理的时候又能出结果?
#define BUFSIZE 64 char * memstr(char *data_1, char *data_2, int len_1, int len_2); int main() { FILE *fp_list, *fpr, *fpw; int i, ret, pre, flag_data_now, flag_data_pre, flag_data_next, flag_temp; char Cmd[BUFSIZE], fname[BUFSIZ], Data[3][BUFSIZE], Data_temp[BUFSIZE*2]; char *p_c_temp1, *p_c_temp2, *p_c_begin, *p_c_end; memset(Cmd, 0, sizeof(Cmd)); memset(Data, 0, sizeof(Data)); if((fp_list = fopen("pcap.lst", "r"))==NULL) return 0; while(1) { memset(fname, 0, sizeof(fname)); if(fscanf(fp_list, "%s", fname)==EOF) break; if((fpr=fopen(fname, "rb"))==NULL) continue; sprintf(Cmd, "%s.new", fname); if((fpw = fopen(Cmd, "wb"))==NULL) { fclose(fpr); continue; } flag_data_now = 0; ret = fread(Data[1], 1, BUFSIZE, fpr); pre = 0; p_c_temp2 = NULL; while(1) { if(ret < BUFSIZE) break; flag_data_now = (flag_data_now+1)%3; flag_data_next = (flag_data_now+1)%3; flag_data_pre = (flag_data_now+2)%3; ret = fread(Data[flag_data_next], 1, BUFSIZE, fpr); pre++; flag_temp = 0; p_c_temp1 = (char *)memchr(Data[flag_data_now],0xab,BUFSIZE); p_c_temp2 = Data[flag_data_now]; while(p_c_temp1 != NULL) { if(p_c_temp1-p_c_temp2 > 1) { fwrite(p_c_temp2, 1, p_c_temp1-p_c_temp2-1, fpw); p_c_temp2 = p_c_temp1-1; } if(p_c_temp1 == Data[flag_data_now]) { if((pre==1) || (pre>1 && ((Data[flag_data_pre][BUFSIZE-1]&0xf0) != 0x10))) fwrite(p_c_temp2, 1, p_c_temp1-p_c_temp2+1, fpw); } else { if(((*(p_c_temp1-1))&0xf0) != 0x10) fwrite(p_c_temp2, 1, p_c_temp1-p_c_temp2+1, fpw); else { int temp = p_c_temp1-Data[flag_data_now]; if(temp>2 && temp<(BUFSIZE-2)) if(((*(p_c_temp1+2)&0xff)!=0xab) && ((*(p_c_temp1-2_&0xff)!=0xab)) fwrite(p_c_temp2, 1, p_c_temp1-p_c_temp2+1, fpw); } } if(p_c_temp1 == &Data[flag_data_now][BUFSIZE-1]) { flag_temp++; break; } else if(p_c_temp1 == &Data[flag_data_now][BUFSIZE-2]) { if(((Data[flag_data_now][BUFSIZE-1]&0xf0)!=0x10) || (Data[flag_data_next][0]&0xff!=0xab)) fwrite(p_c_temp1+1, 1, 1, fpw); flag_temp++; break; } p_c_temp2 = p_c_temp1+1; p_c_temp1 = (char *)memchr(p_c_temp2, 0xab, BUFSIZE-(p_c_temp1-Data[flag_data_now]) ); } if(flag_temp==0) fwrite(p_c_temp2, 1, BUFSIZE-(p_c_temp2-Data[flag_data_now]), fpw); } fflush(fpw); fclose(fpr); fclose(fpw); } return 0; } char * memstr(char *data_1, char *data_2, int len_1, int len_2) { int i,j,k=0; for(i=0; i<len_1-len_2; i++) { if(data_1[i]==data_2[0]) for(j=0; j<len_2; j++) if(data_1[i+j]!=data_2[j]) break; if(j==len_2) return data_1+i; } return NULL; }