summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_editimg.cpp
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-06 12:31:18 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-06 12:31:18 +0000
commiteababa10789bc0d73a325291e2854090ee3896cd (patch)
tree67bb315c3e405c622c9fac40f0f473b4ec2b8fc1 /fpdfsdk/fpdf_editimg.cpp
parentc22d671728605bc614dc84ec6a42a5647808b30d (diff)
downloadpdfium-eababa10789bc0d73a325291e2854090ee3896cd.tar.xz
Use CPDF_StreamAcc to data access of CPDF_Stream.
Change-Id: I68b88e013ac542f245dbe7b6889799c814d46eb8 Reviewed-on: https://pdfium-review.googlesource.com/33690 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_editimg.cpp')
-rw-r--r--fpdfsdk/fpdf_editimg.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_editimg.cpp b/fpdfsdk/fpdf_editimg.cpp
index fed1581e2d..7aa93e98ec 100644
--- a/fpdfsdk/fpdf_editimg.cpp
+++ b/fpdfsdk/fpdf_editimg.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/page/cpdf_pageobject.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_name.h"
+#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fpdfapi/render/cpdf_dibsource.h"
#include "fpdfsdk/cpdfsdk_customaccess.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
@@ -221,10 +222,14 @@ FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object,
if (!pImgStream)
return 0;
- uint32_t len = pImgStream->GetRawSize();
- if (buffer && buflen >= len)
- memcpy(buffer, pImgStream->GetRawData(), len);
+ auto streamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pImgStream);
+ streamAcc->LoadAllDataRaw();
+ const uint32_t len = streamAcc->GetSize();
+ if (!buffer || buflen < len)
+ return len;
+
+ memcpy(buffer, streamAcc->GetData(), len);
return len;
}