summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_view.cpp
diff options
context:
space:
mode:
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());
}