From 3305314761a6562dc54005f3e1d0046cdbe0f5c2 Mon Sep 17 00:00:00 2001 From: "dbradley%netscape.com" Date: Fri, 28 Sep 2001 21:49:00 +0000 Subject: [PATCH] Bug 97967 - leak of nsLocalFile on failure. Patch by dbaron, r=dbradley, sr=jband --- .../xpconnect/loader/mozJSComponentLoader.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/js/src/xpconnect/loader/mozJSComponentLoader.cpp index 571fc802f94d..566e0f81ebb0 100644 --- a/js/src/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/src/xpconnect/loader/mozJSComponentLoader.cpp @@ -1136,20 +1136,25 @@ mozJSComponentLoader::GlobalForLocation(const char *aLocation, nsCOMPtr localFile = do_QueryInterface(component); - if (!localFile) - return nsnull; - char *location; // declare before first jump to out: jsval retval; nsXPIDLCString displayPath; FILE* fileHandle; + JSScript *script = nsnull; + if (!localFile) { + global = nsnull; + goto out; + } + localFile->GetURL(getter_Copies(displayPath)); rv = localFile->OpenANSIFileDesc("r", &fileHandle); - if (NS_FAILED(rv)) - return nsnull; + if (NS_FAILED(rv)) { + global = nsnull; + goto out; + } - JSScript *script = + script = JS_CompileFileHandleForPrincipals(cx, global, (const char *)displayPath, fileHandle, jsPrincipals);