summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_view.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-05-03 20:27:05 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-03 20:27:05 +0000
commite7f4d334eff7d396ec0043a97f751483f8cc9e75 (patch)
treeb5a323132bef0a0996c4ae5db2d9586bbba579dd /fpdfsdk/fpdf_view.cpp
parent2c7f71acbca135cf7a63e9fd30e45f430259807f (diff)
downloadpdfium-e7f4d334eff7d396ec0043a97f751483f8cc9e75.tar.xz
Prove that the memory was good at FPDFBitmap_CreateEx() create time.
Diagnostic for the associated bug, not a bugfix. Helps rule out one possible scenario. Bug: chromium:838886 Change-Id: Ia56fda779407daf8e52a8b754800154fd7491ae7 Reviewed-on: https://pdfium-review.googlesource.com/32055 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_view.cpp')
-rw-r--r--fpdfsdk/fpdf_view.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index a31118ff10..f4a761000b 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -27,6 +27,7 @@
#include "core/fpdfdoc/cpdf_viewerpreferences.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/unowned_ptr.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_renderdevice.h"
@@ -854,11 +855,13 @@ FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
default:
return nullptr;
}
+
+ // Ensure external memory is good at least for the duration of this call.
+ UnownedPtr<uint8_t> pChecker(static_cast<uint8_t*>(first_scan));
auto pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
- if (!pBitmap->Create(width, height, fx_format,
- static_cast<uint8_t*>(first_scan), stride)) {
+ if (!pBitmap->Create(width, height, fx_format, pChecker.Get(), stride))
return nullptr;
- }
+
return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
}