From 201683afe4596ae32f7b1ea12dfca52995d59f9d Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 10 Nov 2019 19:11:03 -0500 Subject: Bug 1487082 - Resolve potential for build bustage regarding bad implicit conversion constructors * Part 1: make conversion CTORs explicit. Minor tweaks to conform with new(ish) static analysis rule which flags up implicit single-argument conversion constructors. * Part 2: fix a couple of double-mRefCnt declaration errors. * Part 3: Fix unsafe use of NS_ConvertASCIItoUTF16(). Tag #1273 --- mailnews/compose/src/nsMsgSendLater.h | 2 +- mailnews/compose/src/nsMsgSendPart.h | 2 +- mailnews/compose/src/nsSmtpProtocol.cpp | 4 +++- mailnews/compose/src/nsSmtpProtocol.h | 2 +- mailnews/compose/src/nsURLFetcher.h | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) (limited to 'mailnews/compose/src') diff --git a/mailnews/compose/src/nsMsgSendLater.h b/mailnews/compose/src/nsMsgSendLater.h index 734396acc..7b6cdf8f7 100644 --- a/mailnews/compose/src/nsMsgSendLater.h +++ b/mailnews/compose/src/nsMsgSendLater.h @@ -27,7 +27,7 @@ class SendOperationListener : public nsIMsgSendListener, public nsIMsgCopyServiceListener { public: - SendOperationListener(nsMsgSendLater *aSendLater); + explicit SendOperationListener(nsMsgSendLater *aSendLater); NS_DECL_ISUPPORTS NS_DECL_NSIMSGSENDLISTENER diff --git a/mailnews/compose/src/nsMsgSendPart.h b/mailnews/compose/src/nsMsgSendPart.h index edb5422ea..84d12bbd7 100644 --- a/mailnews/compose/src/nsMsgSendPart.h +++ b/mailnews/compose/src/nsMsgSendPart.h @@ -22,7 +22,7 @@ typedef int (*MSG_SendPartWriteFunc)(const char* line, int32_t size, class nsMsgSendPart { typedef mozilla::mailnews::MimeEncoder MimeEncoder; public: - nsMsgSendPart(nsIMsgSend* state, const char *part_charset = NULL); + explicit nsMsgSendPart(nsIMsgSend* state, const char *part_charset = NULL); virtual ~nsMsgSendPart(); // Note that the destructor also destroys // any children that were added. diff --git a/mailnews/compose/src/nsSmtpProtocol.cpp b/mailnews/compose/src/nsSmtpProtocol.cpp index 54d1e6f64..04347c1d0 100644 --- a/mailnews/compose/src/nsSmtpProtocol.cpp +++ b/mailnews/compose/src/nsSmtpProtocol.cpp @@ -2261,10 +2261,12 @@ nsSmtpProtocol::GetUsernamePassword(nsACString &aUsername, nsCString hostname; rv = smtpServer->GetHostname(hostname); NS_ENSURE_SUCCESS(rv, rv); + nsAutoString hostnameUTF16; + CopyASCIItoUTF16(hostname, hostnameUTF16); const char16_t *formatStrings[] = { - NS_ConvertASCIItoUTF16(hostname).get(), + hostnameUTF16.get(), nullptr }; diff --git a/mailnews/compose/src/nsSmtpProtocol.h b/mailnews/compose/src/nsSmtpProtocol.h index c5dba76e3..c8cbf1406 100644 --- a/mailnews/compose/src/nsSmtpProtocol.h +++ b/mailnews/compose/src/nsSmtpProtocol.h @@ -109,7 +109,7 @@ public: #endif // Creating a protocol instance requires the URL which needs to be run. - nsSmtpProtocol(nsIURI * aURL); + explicit nsSmtpProtocol(nsIURI * aURL); virtual nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer = nullptr) override; virtual nsresult SendData(const char * dataBuffer, bool aSuppressLogging = false) override; diff --git a/mailnews/compose/src/nsURLFetcher.h b/mailnews/compose/src/nsURLFetcher.h index d252b014b..b23a66385 100644 --- a/mailnews/compose/src/nsURLFetcher.h +++ b/mailnews/compose/src/nsURLFetcher.h @@ -85,7 +85,7 @@ private: class nsURLFetcherStreamConsumer : public nsIStreamListener { public: - nsURLFetcherStreamConsumer(nsURLFetcher* urlFetcher); + explicit nsURLFetcherStreamConsumer(nsURLFetcher* urlFetcher); /* additional members */ NS_DECL_ISUPPORTS -- cgit v1.2.3