Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2285)

Unified Diff: core/fxcrt/include/fx_basic.h

Issue 1986453002: Fix binding of null pointer dereference to reference type (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcrt/include/fx_basic.h
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index 7121ffcd0bd81cd8cb4d4932fa18dbd1c7ed4e87..90d0bda8702af16ffed95728659155562ebf1168 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -8,6 +8,7 @@
#define CORE_FXCRT_INCLUDE_FX_BASIC_H_
#include <algorithm>
+#include <cstdlib>
#include <memory>
#include "core/fxcrt/include/fx_memory.h"
@@ -277,7 +278,7 @@ class CFX_ArrayTemplate : public CFX_BasicArray {
const TYPE GetAt(int nIndex) const {
if (nIndex < 0 || nIndex >= m_nSize) {
- return (const TYPE&)(*(volatile const TYPE*)NULL);
+ abort();
}
return ((const TYPE*)m_pData)[nIndex];
}
@@ -292,7 +293,7 @@ class CFX_ArrayTemplate : public CFX_BasicArray {
TYPE& ElementAt(int nIndex) {
if (nIndex < 0 || nIndex >= m_nSize) {
- return *(TYPE*)NULL;
+ abort();
dsinclair 2016/05/16 17:41:02 I don't think this is safe to do. We can't assume
hans 2016/05/16 17:48:26 Getting a reference bound to null as the return va
Tom Sepez 2016/05/16 17:49:18 But .. they wanted to crash here, so this should b
Nico 2016/05/16 17:49:34 References pointing to null have undefined behavio
}
return ((TYPE*)m_pData)[nIndex];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698