summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurtis Schlepp <mopriadevteam@gmail.com>2021-06-23 11:22:10 -0700
committerErik Wolsheimer <ewol@google.com>2021-06-24 17:21:53 +0000
commit735ca398d101c05baa51d0f196c1f2ab5a8d0779 (patch)
tree2708fb0438a31dcdbd9f1924b8eb04064e6dbfcb
parent8b611e6994bf61c3fdf87b45eeb617c0cc02a457 (diff)
downloadplatform_packages_services_BuiltInPrintService-735ca398d101c05baa51d0f196c1f2ab5a8d0779.tar.gz
platform_packages_services_BuiltInPrintService-735ca398d101c05baa51d0f196c1f2ab5a8d0779.tar.bz2
platform_packages_services_BuiltInPrintService-735ca398d101c05baa51d0f196c1f2ab5a8d0779.zip
fix crash when printing to pclm supporting printers
Account for the margin when copying data. Prevents writing to memory that has not been allocated. Bug: 187662332 Test: Print to a printer that supports pclm Signed-off-by: Kurtis Schlepp <mopriadevteam@gmail.com> Change-Id: Idb703f65f6641ddc3a477c3077c53c6c6f61c30b
-rw-r--r--jni/plugins/genPCLm/src/genPCLm.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/jni/plugins/genPCLm/src/genPCLm.cpp b/jni/plugins/genPCLm/src/genPCLm.cpp
index 0aab701..a9a6ac4 100644
--- a/jni/plugins/genPCLm/src/genPCLm.cpp
+++ b/jni/plugins/genPCLm/src/genPCLm.cpp
@@ -60,9 +60,8 @@ static ubyte *shiftStripByLeftMargin(ubyte *ptrToStrip, sint32 currSourceWidth,
if (destColorSpace == grayScale) {
scanLineWidth = currMediaWidth;
-
// Allocate a full strip
- newStrip = (ubyte *) malloc(scanLineWidth * currStripHeight);
+ newStrip = (ubyte *) malloc((scanLineWidth * currStripHeight) + leftMargin);
memset(newStrip, 0xff, scanLineWidth * currStripHeight);
for (int i = 0; i < numLinesThisCall; i++) {
toPtr = newStrip + leftMargin + (i * currMediaWidth);
@@ -73,7 +72,7 @@ static ubyte *shiftStripByLeftMargin(ubyte *ptrToStrip, sint32 currSourceWidth,
scanLineWidth = currMediaWidth * 3;
sint32 srcScanlineWidth = currSourceWidth * 3;
sint32 shiftAmount = leftMargin * 3;
- newStrip = (ubyte *) malloc(scanLineWidth * currStripHeight);
+ newStrip = (ubyte *) malloc((scanLineWidth * currStripHeight) + shiftAmount);
memset(newStrip, 0xff, scanLineWidth * currStripHeight);
for (int i = 0; i < numLinesThisCall; i++) {
toPtr = newStrip + shiftAmount + (i * scanLineWidth);