CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the bug here?



> Can anyone tell me what is wrong with the following code?  It is producing
> and Invalid Pointer Operation after calling it two or three times:
> 
> bool OpenItem(TComponent *Caller, TStringField *Path, TStringField
> *Keywords, TGraphicField *ItemBinary)
> {
> 
>  frmRichNote=new TfrmRichNote(NULL);
>  frmRichNote->name->Text=Path->Value;
>     frmRichNote->keywords->Text=Keywords->Value;
>     delete frmRichNote;
>      return false;
> }

Is it possible that either Path or Keywords is a null pointer??? Add 
a check like this as a first try check:

if (!Path || !Keywords)
	return false;

.. or something along those lines..  My guess is that either Path or 
Keywords is invalid (be it null or an already deleted object), thus 
when you de-reference it, it explodes.. catching null is easy as 
shown above.. catching a deleted object is very tricky.. if the null 
trick doesn't work.. look closely at where the pointers are coming 
from, and who has touched them, or other pointers pointing the same 
place..

>Path, Keywords, and ItemBinary are from a Paradox Table which is in
>edit mode.  The fields are being passed as pointers to this 
>function.

Is it possible your pointers are "stale" (ie: pointing to rows that 
have since been removed from the database)?  (just a possibility)



W Komornicki's Home Page | Main Index | Thread Index