From d17cfb0becb138733744b6f05520aa21dcd97d67 Mon Sep 17 00:00:00 2001 From: "mats.palmgren%bredband.net" Date: Fri, 25 Apr 2008 10:48:57 +0000 Subject: [PATCH] Add error handling for invalid filename. b=429707 r+sr=roc a1.9=beltzner --- widget/src/gtk2/nsPrintSettingsGTK.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/widget/src/gtk2/nsPrintSettingsGTK.cpp b/widget/src/gtk2/nsPrintSettingsGTK.cpp index ca756fdad0d..5197ccced7a 100644 --- a/widget/src/gtk2/nsPrintSettingsGTK.cpp +++ b/widget/src/gtk2/nsPrintSettingsGTK.cpp @@ -418,15 +418,20 @@ nsPrintSettingsGTK::GetToFileName(PRUnichar * *aToFileName) // Convert to an nsIFile nsCOMPtr file; - NS_GetFileFromURLSpec(nsDependentCString(gtk_output_uri), getter_AddRefs(file)); + nsresult rv = NS_GetFileFromURLSpec(nsDependentCString(gtk_output_uri), + getter_AddRefs(file)); + if (NS_FAILED(rv)) + return rv; // Extract the path nsAutoString path; - file->GetPath(path); + rv = file->GetPath(path); + NS_ENSURE_SUCCESS(rv, rv); *aToFileName = ToNewUnicode(path); return NS_OK; } + NS_IMETHODIMP nsPrintSettingsGTK::SetToFileName(const PRUnichar * aToFileName) { @@ -443,11 +448,14 @@ nsPrintSettingsGTK::SetToFileName(const PRUnichar * aToFileName) } nsCOMPtr file; - NS_NewLocalFile(nsDependentString(aToFileName), PR_TRUE, getter_AddRefs(file)); + nsresult rv = NS_NewLocalFile(nsDependentString(aToFileName), PR_TRUE, + getter_AddRefs(file)); + NS_ENSURE_SUCCESS(rv, rv); // Convert the nsIFile to a URL nsCAutoString url; - NS_GetURLSpecFromFile(file, url); + rv = NS_GetURLSpecFromFile(file, url); + NS_ENSURE_SUCCESS(rv, rv); gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_URI, url.get()); mToFileName = aToFileName;