delphi TStringList.free 释放错误 invalid pointer operation

var
   NeedStr : TStringList;
 begin
  NeedStr := TStringList.Create;

.....

try

   ......

tinally

  needstr.free;  /// 如果needstr值为nil时,直接释放会产生  invalid pointer operation 错误提示.

 //应该改为:       if NeedStr.Count>0 then NeedStr.Free;       

end;

 

posted @ 2014-11-07 17:38  聪明的小蚂蚁  阅读(870)  评论(0编辑  收藏  举报