From 7a2f0813628acebb6b5c17e847e5c0b45a371bc6 Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Fri, 27 Aug 1999 10:17:03 +0000 Subject: [PATCH] Don't ignore Eval error under GetLength; do control error from EvaluateString (and reuse rv!). git-svn-id: svn://10.0.0.236/trunk@44799 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp index 39c6b274c4f..6a6e9b6d116 100644 --- a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -79,7 +79,9 @@ public: NS_IMETHOD GetLength(PRUint32 *_retval) { if (!mResult) { - Eval(); + nsresult rv = Eval(); + if (NS_FAILED(rv)) + return rv; NS_ASSERTION(mResult, "Eval didn't set mResult"); } PRUint32 rest = mLength - mReadCursor; @@ -135,17 +137,17 @@ public: // Finally, we have everything needed to evaluate the expression. nsAutoString ret; PRBool isUndefined; - nsresult ok; - ok = scriptContext->EvaluateString(nsString(jsExpr), - nsnull, 0, ret, &isUndefined); + rv = scriptContext->EvaluateString(nsString(jsExpr), nsnull, 0, ret, + &isUndefined); nsCRT::free(jsExpr); - if (NS_SUCCEEDED(ok)) { -// JSContext* cx = (JSContext*)scriptContext->GetNativeContext(); + if (NS_FAILED(rv)) { + rv = NS_ERROR_MALFORMED_URI; + } else { // Find out if it can be converted into a string if (isUndefined) { mResult = nsCRT::strdup(""); } else { -#if 0 // plaintext is apparently busted +#if 0 // plaintext is apparently busted if (ret[0] != PRUnichar('<')) ret.Insert("\n", 0); #endif