Board index » delphi » HELP - Invalid Pointer Operation

HELP - Invalid Pointer Operation

I have been wrestling with a strange EInvalidPointer error that is,
apparently, an Invalid Pointer Operation.

The following code (very ineffieint and stretched out due to my
troubleshooting) is where the error occurs:

function DoCheckin:Boolean;
var
   sArchive1, sArchive2, sWork1, sWork2 : string;
   pcArchive1, pcArchive2, pcWork1, pcWork2 : PChar;

begin
     sArchive1 := GenGetINIString('ArchiveSource') + sIsOut + '.IFV';
     sArchive2 := GenGetINIString('ArchiveSource') + sIsOut + '.PRV';
     sWork1 :=GenGetINIString('LocalDirectory');
     sWork2 :=GenGetINIString('LocalDirectory');
     sWork1 := sWork1 + sIsOut + '.IFD';
     sWork2 := sWork2 + sIsOut + '.PRE';

     GetMem(pcArchive1, Length(sArchive1));
     StrPCopy(pcArchive1, sArchive1);
     GetMem(pcArchive2, Length(sArchive2));
     StrPCopy(pcArchive2, sArchive2);
     GetMem(pcWork1, Length(sWork1));
     StrPCopy(pcWork1, sWork1);
     GetMem(pcWork2, Length(sWork2));
     StrPCopy(pcWork2, sWork2);

     PVCS1.NewArchive(pcArchive1, pcWork1);
     PVCS1.NewArchive(pcArchive2, pcWork2);

     FreeMem(pcArchive1, Length(sArchive1));
     FreeMem(pcArchive2, Length(sArchive2));
     FreeMem(pcWork2, Length(sWork2));
     FreeMem(pcWork1, Length(sWork1));

     bHaveCheckout:= False;
     Result := True;
end;

PVCS1 is a special object enwrapping DLL calls.  At this time it does NOT
affect the passed PChars.

GenGetINIString is a wrapper for getting INI file information.

The error ONLY occurs when pcWork2 is freed.  Only if it uses the INI
information aquired, and then ONLY if the addition of additional strings
to it is done.  I am completely confused.

ANY help is appreciated, PLEASE write bad...@infinet.com.  This is
impeding more sophisticated development!

--
BADGER
(aka Steve Savage)
------------------------------------------------------------------
Badger's Den:
http://www.infinet.com/~badger

MEMBER OF:
Association of Internet Professionals: http://www.association.org/
Java Lobby: http://www.javalobby.com/
------------------------------------------------------------------

 

Re:HELP - Invalid Pointer Operation


Steve
As a start, you appear to have not  allocated enough memory for the string,
help on StrPCopy says "The destination buffer must have room for at least
Length(Source)+1 characters."

Alan Lloyd
alangll...@aol.com

In article <6cfhr5$...@news1.infinet.com>, bad...@infinet.com (Steven Savage)
writes:

Quote
>I have been wrestling with a strange EInvalidPointer error that is,
>apparently, an Invalid Pointer Operation.

>The following code (very ineffieint and stretched out due to my
>troubleshooting) is where the error occurs:

>function DoCheckin:Boolean;
>var
>   sArchive1, sArchive2, sWork1, sWork2 : string;
>   pcArchive1, pcArchive2, pcWork1, pcWork2 : PChar;

<snip>

>     GetMem(pcArchive1, Length(sArchive1));
>     StrPCopy(pcArchive1, sArchive1);
>     GetMem(pcArchive2, Length(sArchive2));
>     StrPCopy(pcArchive2, sArchive2);
>     GetMem(pcWork1, Length(sWork1));
>     StrPCopy(pcWork1, sWork1);
>     GetMem(pcWork2, Length(sWork2));
>     StrPCopy(pcWork2, sWork2);

<snip>

>ANY help is appreciated, PLEASE write bad...@infinet.com.  This is
>impeding more sophisticated development!

Other Threads