From 0d9360ceabca340c12bc08818d768213614074e2 Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Sat, 2 Oct 1999 00:41:03 +0000 Subject: [PATCH] Fixing #13783 (garbage-pointer dereference) --- modules/plugin/base/src/nsPluginHostImpl.cpp | 3 +++ modules/plugin/base/src/nsPluginsDirWin.cpp | 2 +- modules/plugin/nglsrc/nsPluginHostImpl.cpp | 3 +++ modules/plugin/nglsrc/nsPluginsDirWin.cpp | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 4f6f6e96509..edda8cd00b4 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -109,6 +109,9 @@ nsPluginTag::nsPluginTag() inline char* new_str(char* str) { + if(str == nsnull) + return nsnull; + char* result = new char[strlen(str) + 1]; if (result != nsnull) return strcpy(result, str); diff --git a/modules/plugin/base/src/nsPluginsDirWin.cpp b/modules/plugin/base/src/nsPluginsDirWin.cpp index c8d430a0ee3..14740d57a81 100644 --- a/modules/plugin/base/src/nsPluginsDirWin.cpp +++ b/modules/plugin/base/src/nsPluginsDirWin.cpp @@ -92,7 +92,7 @@ static char** MakeStringArray(PRUint32 variants, char* data) if((variants == 0) || (data == NULL)) return NULL; - buffer = (char **)PR_Malloc(variants * sizeof(char *)); + buffer = (char **)PR_Calloc(variants, sizeof(char *)); if(!buffer) return NULL; buffer[count] = index; diff --git a/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 4f6f6e96509..edda8cd00b4 100644 --- a/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -109,6 +109,9 @@ nsPluginTag::nsPluginTag() inline char* new_str(char* str) { + if(str == nsnull) + return nsnull; + char* result = new char[strlen(str) + 1]; if (result != nsnull) return strcpy(result, str); diff --git a/modules/plugin/nglsrc/nsPluginsDirWin.cpp b/modules/plugin/nglsrc/nsPluginsDirWin.cpp index c8d430a0ee3..14740d57a81 100644 --- a/modules/plugin/nglsrc/nsPluginsDirWin.cpp +++ b/modules/plugin/nglsrc/nsPluginsDirWin.cpp @@ -92,7 +92,7 @@ static char** MakeStringArray(PRUint32 variants, char* data) if((variants == 0) || (data == NULL)) return NULL; - buffer = (char **)PR_Malloc(variants * sizeof(char *)); + buffer = (char **)PR_Calloc(variants, sizeof(char *)); if(!buffer) return NULL; buffer[count] = index;