From 3977a68842b1602b66188b89b2555eddd234c4a9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 24 Oct 2009 23:35:17 +0000 Subject: [PATCH] fix obscure firefox crash --- direct/src/plugin_npapi/ppInstance.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 56d35a13e7..53f46bdb88 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -57,10 +57,18 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16 mode, // Copy the tokens and save them within this object. _tokens.reserve(argc); for (int i = 0; i < argc; ++i) { - P3D_token token; - token._keyword = strdup(argn[i]); - token._value = strdup(argv[i]); - _tokens.push_back(token); + if (argn[i] != NULL) { + const char *v = argv[i]; + if (v == NULL) { + // Firefox might give us a NULL argv[i] in some cases. + v = ""; + } + + P3D_token token; + token._keyword = strdup(argn[i]); + token._value = strdup(v); + _tokens.push_back(token); + } } _root_dir = global_root_dir;