View Issue Details

IDProjectCategoryView StatusLast Update
0027970LazarusPrinterpublic2015-04-29 07:10
ReporterDaLiVAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64 / i386OSWindowsOS Version8.1
Product Version1.5 (SVN)Product Build 
Target Version1.6Fixed in Version1.5 (SVN) 
Summary0027970: some default printers cause error
Descriptionprinter that does not report devmodesize must not allocate memory size
Steps To Reproduceinstall 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 Informationpatch :
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;

TagsNo tags attached.
Fixed in Revision48887
LazTarget1.6
WidgetsetWin32/Win64
Attached Files

Activities

Jesus Reyes

2015-04-29 07:10

developer   ~0083314

Thanks, applied.

Additionally, if returned size <0 then the function should fail, added that check. Please tests.

Issue History

Date Modified Username Field Change
2015-04-26 15:25 DaLiV New Issue
2015-04-26 20:41 Jesus Reyes Assigned To => Jesus Reyes
2015-04-26 20:41 Jesus Reyes Status new => assigned
2015-04-29 07:10 Jesus Reyes Fixed in Revision => 48887
2015-04-29 07:10 Jesus Reyes LazTarget => 1.6
2015-04-29 07:10 Jesus Reyes Note Added: 0083314
2015-04-29 07:10 Jesus Reyes Status assigned => resolved
2015-04-29 07:10 Jesus Reyes Fixed in Version => 1.5 (SVN)
2015-04-29 07:10 Jesus Reyes Resolution open => fixed
2015-04-29 07:10 Jesus Reyes Target Version => 1.6