some default printers cause error
Original Reporter info from Mantis: DaLiV
-
Reporter name: DaLiV
Original Reporter info from Mantis: DaLiV
- Reporter name: DaLiV
Description:
printer that does not report devmodesize must not allocate memory size
Steps to reproduce:
install pdfcreator 1.7.3, set it as default
make project which use printers
occurs error RunErro(204) / EInvalidPointer
trace call to function
PDev.DevModeSize := DocumentPropertiesW(0, FPrinterHandle,Pwidechar(UTF8Decode(PDev.Name)),nil, nil, 0);
reutrns -1
and next line called with size "-1" - that is too big:
ReallocMem(Pdev.DevModeW, PDev.DevModeSize);
Additional information:
patch :
Index: winprinters.inc
===================================================================
--- winprinters.inc (revision 48817)
+++ winprinters.inc (working copy)
@@ -257,13 +257,15 @@
begin
PDev.DevModeSize := DocumentPropertiesW(0, FPrinterHandle, Pwidechar(UTF8Decode(PDev.Name)),
nil, nil, 0);
- ReallocMem(Pdev.DevModeW, PDev.DevModeSize);
+ if PDev.DevModeSize>0 then
+ ReallocMem(Pdev.DevModeW, PDev.DevModeSize);
end
else
begin
PDev.DevModeSize := DocumentProperties(0, FPrinterHandle, pchar(PDev.Name),
nil, nil, 0);
- ReallocMem(Pdev.DevModeA, PDev.DevModeSize);
+ if PDev.DevModeSize>0 then
+ ReallocMem(Pdev.DevModeA, PDev.DevModeSize);
end;
if PDev.DevModeSize=0 then begin
result := false;
Mantis conversion info:
- Mantis ID: 27970
- OS: Windows
- OS Build: 8.1
- Platform: x86_64 / i386
- Version: 1.5 (SVN)
- Fixed in version: 1.5 (SVN)
- Fixed in revision: 48887 (#28089b25)
- Target version: 1.6