From 6fb110e776a52a95c17fb38d453771d23cc92af7 Mon Sep 17 00:00:00 2001 From: Siqi Liu Date: Tue, 28 Jun 2016 09:33:52 -0700 Subject: [PATCH] Add nullcheck in ExceptionsManager.js to Never Update JS Exception with a Null Stack Summary: JS codes sometimes report exceptions with `null` details about stack traces, resulting in native `NullPointerException` crashes when parsing the stack traces. Added null checking for the stack traces in `ExceptionsManager.js`, ensuring that we never call `updateExceptionMessage` with a null stack Reviewed By: foghina Differential Revision: D3455783 fbshipit-source-id: 027969afd8a5d6015e97fce0a26626730cfc83a4 --- .../Initialization/ExceptionsManager.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js b/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js index e5eae65b4..699228de4 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js +++ b/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js @@ -31,8 +31,14 @@ function reportException(e: Error, isFatal: bool) { } if (__DEV__) { symbolicateStackTrace(stack).then( - (prettyStack) => - RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack, currentExceptionID), + (prettyStack) => { + if (prettyStack) { + RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack, currentExceptionID); + } else { + throw new Error('The stack is null'); + } + } + ).catch( (error) => console.warn('Unable to symbolicate stack trace: ' + error.message) );