Access Violation at address 00000000.Read of address 00000000 解决办法

是数组越标或没有初始化某个对象之类的问题,搂住细细检查一下代码,

 

使用指针前未做检查,而这个指针未初始化。 

 

可能是new后没有delete,这样出现溢出的可能性比较大   
  检查代码或者跟踪试试

 

使用指针对象前判断一下   if   (ptr!=NULL)     
  delete   指针对象后,指针置NULL;基本能防止此类问题。  

 


 

Access  violation  at  address  ×××  in  module    "Project1.exe "      Read  of  address  000000 

这个主要是访问了一个没有被初始化的内存地址。 
通过try ... catch来定位错误,如果懂得使用map文件来查错误则只须在编译选项当中输出map文件,否则的话,就自己记录执行过了哪一行,然后在catch当中 写出exception日志,从而达到定位的目的,只有定位到问题代码才能解决问题。另外,任何一个new都需要判断结果是不是没有分配到内存,并且记录 下LastError,以及位置。

 

 

Delphi Access violations 问题的解决之道

http://www.wesoho.com/article/Delphi/1403.htm

 


 

我的错误找到了

if (p[5]='*') and (p[8]='*') and ( p[9]='*') and (p[10]='%') then  // 
  begin 

  memo1.lines.add('viewstring'); 
  end;

 

 

改成这样: 
  if (p <> nil) and (p[5]='*') and (p[8]='*') and (p[9]='*') and (p[10]='%') then 

否则rbuf中没有出来#**时, 执行这行 
p := StrPos(pchar(@rbuf), '#**'); 
之后, p为空指针

 

p的长度不到10,p[10]怎么能行呢?

 

判断是否为Nil,判断长度是否大于等于10才行

 


 

  i:=StrLen(p);//这一句还有问题 运行时间一长出错   去掉这一句 好了   

  if (p<>nil) and  (i>14) and (p[11]='*') and ( p[12]='*') and (p[13]='%') then  //
  begin

    ----------

  end; 

 

http://blog.csdn.net/yunqian09/article/details/5323995

posted @ 2016-03-26 05:43  findumars  Views(4289)  Comments(0Edit  收藏  举报