New GPC beta: gpc-971001_(re)

Wed, 08 Oct 1997 11:58:25 -0700


Peter Gerwinski wrote:
> Frank has tracked down this error to the following:
> :
> : unit system;
> : interface
> : implementation
> :
> : var junk:integer;
> :
> : to begin do
> :   for junk := 1 to 1 do;
> :
> : end.

There is another error in this initialization part (which presumably has
nothing to do with the crash of the compiler).
The variable ppJunk is New'ed, used to fill CmdLine, which is a pointer
of pChar type, Then Dispose'd. So the memory to which CmdLine points is
reputted into the heap, and can be overwrited by subsequent instructions
in the main program.
 The following shot program displays the bug:

program Essai;
{$x+}
uses gpctypes, system;

var pBug:^String1024;
begin
   writeln(cmdline);
   new(pBug); pBug^:='Non!!!';
   writeln(cmdline);
end.

when compiled and called with

essai Oui!!! 

it OutPuts

Oui!!!
Non!!!

Hope that it helps


Maurice Lombardi (Maurice.LOMBARDI@ujf-grenoble.fr)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es