Chromium Code Reviews| 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]; |
| } |