| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 #define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH | 216 #define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH |
| 217 | 217 |
| 218 #else | 218 #else |
| 219 | 219 |
| 220 #define ASSERT(assertion) ((void)0) | 220 #define ASSERT(assertion) ((void)0) |
| 221 #define ASSERT_NOT_REACHED() ((void)0) | 221 #define ASSERT_NOT_REACHED() ((void)0) |
| 222 #define NO_RETURN_DUE_TO_ASSERT | 222 #define NO_RETURN_DUE_TO_ASSERT |
| 223 | 223 |
| 224 #endif | 224 #endif |
| 225 | 225 |
| 226 // ASSERT_WITH_SECURITY_IMPLICATION | |
| 227 // It is deprecated. ASSERT_WITH_SECURITY_IMPLICATION should be replaced | |
| 228 // with SECURITY_DCHECK. | |
| 229 #ifdef ADDRESS_SANITIZER | |
| 230 | |
| 231 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \ | |
| 232 (!(assertion) ? (WTFReportAssertionFailure(__FILE__, __LINE__, \ | |
| 233 WTF_PRETTY_FUNCTION, #assertion), \ | |
| 234 CRASH()) \ | |
| 235 : (void)0) | |
| 236 | |
| 237 #else | |
| 238 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT(assertion) | |
| 239 #endif | |
| 240 | |
| 241 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 226 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
| 242 // that code testing this macro has included this header. | 227 // that code testing this macro has included this header. |
| 243 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) | 228 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) |
| 244 #define ENABLE_SECURITY_ASSERT 1 | 229 #define ENABLE_SECURITY_ASSERT 1 |
| 245 #else | 230 #else |
| 246 #define ENABLE_SECURITY_ASSERT 0 | 231 #define ENABLE_SECURITY_ASSERT 0 |
| 247 #endif | 232 #endif |
| 248 | 233 |
| 249 // SECURITY_DCHECK and SECURITY_CHECK | 234 // SECURITY_DCHECK and SECURITY_CHECK |
| 250 // Use in places where failure of the assertion indicates a possible security | 235 // Use in places where failure of the assertion indicates a possible security |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 return !(a == b); \ | 283 return !(a == b); \ |
| 299 } \ | 284 } \ |
| 300 inline bool operator!=(const thisType& a, const thisType* b) { \ | 285 inline bool operator!=(const thisType& a, const thisType* b) { \ |
| 301 return !(a == b); \ | 286 return !(a == b); \ |
| 302 } \ | 287 } \ |
| 303 inline bool operator!=(const thisType* a, const thisType& b) { \ | 288 inline bool operator!=(const thisType* a, const thisType& b) { \ |
| 304 return !(a == b); \ | 289 return !(a == b); \ |
| 305 } | 290 } |
| 306 | 291 |
| 307 // DEFINE_TYPE_CASTS | 292 // DEFINE_TYPE_CASTS |
| 308 // Provide static_cast<> wrappers with ASSERT_WITH_SECURITY_IMPLICATION for bad | 293 // Provide static_cast<> wrappers with SECURITY_DCHECK for bad casts. |
| 309 // casts. | 294 #define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, \ |
| 310 #define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, \ | 295 pointerPredicate, referencePredicate) \ |
| 311 pointerPredicate, referencePredicate) \ | 296 inline thisType* to##thisType(argumentType* argumentName) { \ |
| 312 inline thisType* to##thisType(argumentType* argumentName) { \ | 297 SECURITY_DCHECK(!argumentName || (pointerPredicate)); \ |
| 313 ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \ | 298 return static_cast<thisType*>(argumentName); \ |
| 314 return static_cast<thisType*>(argumentName); \ | 299 } \ |
| 315 } \ | 300 inline const thisType* to##thisType(const argumentType* argumentName) { \ |
| 316 inline const thisType* to##thisType(const argumentType* argumentName) { \ | 301 SECURITY_DCHECK(!argumentName || (pointerPredicate)); \ |
| 317 ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \ | 302 return static_cast<const thisType*>(argumentName); \ |
| 318 return static_cast<const thisType*>(argumentName); \ | 303 } \ |
| 319 } \ | 304 inline thisType& to##thisType(argumentType& argumentName) { \ |
| 320 inline thisType& to##thisType(argumentType& argumentName) { \ | 305 SECURITY_DCHECK(referencePredicate); \ |
| 321 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 306 return static_cast<thisType&>(argumentName); \ |
| 322 return static_cast<thisType&>(argumentName); \ | 307 } \ |
| 323 } \ | 308 inline const thisType& to##thisType(const argumentType& argumentName) { \ |
| 324 inline const thisType& to##thisType(const argumentType& argumentName) { \ | 309 SECURITY_DCHECK(referencePredicate); \ |
| 325 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 310 return static_cast<const thisType&>(argumentName); \ |
| 326 return static_cast<const thisType&>(argumentName); \ | 311 } \ |
| 327 } \ | 312 void to##thisType(const thisType*); \ |
| 328 void to##thisType(const thisType*); \ | |
| 329 void to##thisType(const thisType&) | 313 void to##thisType(const thisType&) |
| 330 | 314 |
| 331 #endif // WTF_Assertions_h | 315 #endif // WTF_Assertions_h |
| OLD | NEW |