From 6caac7613ed5ca53ae51dfb41d9692f8126724aa Mon Sep 17 00:00:00 2001 From: Jonathan Griffin Date: Fri, 30 Oct 2009 13:15:22 -0700 Subject: [PATCH] Bug 523216. Check for NULL message in NPN_SetException. r=joshmoz --- modules/plugin/base/src/nsNPAPIPlugin.cpp | 2 ++ .../mochitest/test_npruntime_npnsetexception.html | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/plugin/base/src/nsNPAPIPlugin.cpp b/modules/plugin/base/src/nsNPAPIPlugin.cpp index bda4031dcdae..08d124e6016e 100644 --- a/modules/plugin/base/src/nsNPAPIPlugin.cpp +++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp @@ -1791,6 +1791,8 @@ _setexception(NPObject* npobj, const NPUTF8 *message) return; } + if (!message) return; + if (gNPPException) { // If a plugin throws multiple exceptions, we'll only report the // last one for now. diff --git a/modules/plugin/test/mochitest/test_npruntime_npnsetexception.html b/modules/plugin/test/mochitest/test_npruntime_npnsetexception.html index f34d0d6d12f3..137721a34016 100644 --- a/modules/plugin/test/mochitest/test_npruntime_npnsetexception.html +++ b/modules/plugin/test/mochitest/test_npruntime_npnsetexception.html @@ -38,7 +38,17 @@ catch (e) { is(e, "second exception", "wrong exception thrown"); } - + + // test calling exception with NULL message + plugin.throwExceptionNextInvoke(); + try { + plugin(); + ok(false, "exception not thrown"); + } + catch (e) { + is(e.message, "Error calling method on NPObject!", "wrong exception thrown"); + } + SimpleTest.finish(); }