summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_parser
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-05-19 14:56:52 -0700
committerTom Sepez <tsepez@chromium.org>2015-05-19 14:56:52 -0700
commitbf4aa2cc93a67826247e887b2ba26a1b965eb616 (patch)
treea1d6336676d6d70467a7fb94aa0e625b1dbc8c25 /core/src/fpdfapi/fpdf_parser
parenteb6527763171cdb4b0fbfea5a20d691f4d67b660 (diff)
downloadpdfium-bf4aa2cc93a67826247e887b2ba26a1b965eb616.tar.xz
Revert "Remove FX_Alloc() null checks now that it can't return NULL."
This reverts commit eb6527763171cdb4b0fbfea5a20d691f4d67b660. Reason for revert: broke javascript tests. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1145843005
Diffstat (limited to 'core/src/fpdfapi/fpdf_parser')
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp5
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp3
3 files changed, 13 insertions, 1 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 691981cb10..8f5871df7f 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -40,6 +40,9 @@ FX_DWORD _A85Decode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_b
return (FX_DWORD) - 1;
}
dest_buf = FX_Alloc(FX_BYTE, zcount * 4 + (pos - zcount));
+ if (dest_buf == NULL) {
+ return (FX_DWORD) - 1;
+ }
int state = 0;
FX_UINT32 res = 0;
pos = dest_size = 0;
@@ -150,6 +153,9 @@ FX_DWORD RunLengthDecode(const FX_BYTE* src_buf, FX_DWORD src_size, FX_LPBYTE& d
return -1;
}
dest_buf = FX_Alloc( FX_BYTE, dest_size);
+ if (!dest_buf) {
+ return -1;
+ }
i = 0;
int dest_count = 0;
while (i < src_size) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index 341be13d44..3eac5ae74e 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -1086,7 +1086,7 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, FX_BOOL bRawAccess,
}
if (!pStream->IsMemoryBased()) {
pSrcData = m_pSrcData = FX_Alloc(FX_BYTE, dwSrcSize);
- if (!pStream->ReadRawData(0, pSrcData, dwSrcSize)) {
+ if (!pSrcData || !pStream->ReadRawData(0, pSrcData, dwSrcSize)) {
return;
}
} else {
@@ -1165,6 +1165,9 @@ FX_LPBYTE CPDF_StreamAcc::DetachData()
return p;
}
FX_LPBYTE p = FX_Alloc(FX_BYTE, m_dwSize);
+ if (p == NULL) {
+ return NULL;
+ }
FXSYS_memcpy32(p, m_pData, m_dwSize);
return p;
}
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 0d4ed27c06..2772d9825e 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2477,6 +2477,9 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT
}
CPDF_Stream* pStream;
FX_LPBYTE pData = FX_Alloc(FX_BYTE, len);
+ if (!pData) {
+ return NULL;
+ }
ReadBlock(pData, len);
if (pCryptoHandler) {
CFX_BinaryBuf dest_buf;