trident-job / delphi-code-coverage

Automatically exported from code.google.com/p/delphi-code-coverage
0 stars 0 forks source link

Access violation in TCoverageConfiguration.ExpandEnvString #61

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Insert a blank line at the end of dcov_paths.lst and run CodeCoverage 
normally.

What is the expected output? What do you see instead?

Expected: Successful run. Actual: Access violation in ntdll.dll.

What version of the product are you using? On what operating system?

1.0 RC10, Delphi XE2, Win7 x64

Please provide any additional information below.

The problem due to is a bug in TCoverageConfiguration.ExpandEnvString:

These lines:

  SetLength(Result, Size - 1);
  ExpandEnvironmentStrings(PChar(APath), PChar(Result), Size);

should be:

  SetLength(Result, Size);
  ExpandEnvironmentStrings(PChar(APath), PChar(Result), Size);
  Result := PChar(Result);

What's happening with the existing code is that the API call is overwriting 
memory with the #0 at the end of the PChar string. It's only by pure luck that 
it (usually) won't overwrite anything valuable.

-Steve

Original issue reported on code.google.com by pand...@telepath.com on 17 Oct 2014 at 11:28

GoogleCodeExporter commented 9 years ago

Original comment by e.kotlya...@gmail.com on 20 Oct 2014 at 8:19

GoogleCodeExporter commented 9 years ago
This is fixed in current trunk

Original comment by e.kotlya...@gmail.com on 31 Oct 2014 at 6:52