Closed Bug 1399336 Opened 7 years ago Closed 7 years ago

Memory leak of prtName into widget/nsOptionsImpl.cpp

Categories

(Core :: Printing: Output, defect)

x86
Windows
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: mantaroh, Assigned: mantaroh)

Details

Attachments

(1 file)

As far as I can see, the gecko will not release an allocated prtName[1] and char16_t invariable of WritePref function.[2]

[1] http://searchfox.org/mozilla-central/rev/e76c0fee79a34a3612740b33508276f4b37c3ee8/widget/nsPrintOptionsImpl.cpp#1108-1113
[2] http://searchfox.org/mozilla-central/rev/e76c0fee79a34a3612740b33508276f4b37c3ee8/widget/nsPrintOptionsImpl.cpp#768,803

Like the following code: 
----------------------------------------------------------
GetAdjustedPrinterName(nsIPrintSettings* aPS, bool aUsePNP,
                       nsAString& aPrinterName)
{
  NS_ENSURE_ARG_POINTER(aPS);

  aPrinterName.Truncate();
  if (!aUsePNP)
    return NS_OK;

  // Get the Printer Name from the PrintSettings
  // to use as a prefix for Pref Names
  char16_t* prtName = nullptr;

  nsresult rv = aPS->GetPrinterName(&prtName);
  NS_ENSURE_SUCCESS(rv, rv);

  aPrinterName = nsDependentString(prtName);
....
}
----------------------------------------------------------

DMD Result:
----------------------------------------------------------
Unreported {
  1 block in heap block record 904 of 1,313
  48 bytes (46 requested / 2 slop)
  0.00% of the heap (37.12% cumulative)
  0.00% of unreported (99.86% cumulative)
  Allocated at {
    #01: replace_malloc (c:\work\mozilla-central\memory\replace\dmd\dmd.cpp:1301)
    #02: moz_xmalloc (c:\work\mozilla-central\memory\mozalloc\mozalloc.cpp:84)
    #03: AllocateStringCopy<nsAString,char16_t> (c:\work\mozilla-central\xpcom\string\nsreadableutils.cpp:417)
    #04: ToNewUnicode (c:\work\mozilla-central\xpcom\string\nsreadableutils.cpp:485)
    #05: nsPrintSettings::GetPrinterName (c:\work\mozilla-central\widget\nsprintsettingsimpl.cpp:199)
    #06: GetAdjustedPrinterName (c:\work\mozilla-central\widget\nsprintoptionsimpl.cpp:1110)
    #07: nsPrintOptions::InitPrintSettingsFromPrefs (c:\work\mozilla-central\widget\nsprintoptionsimpl.cpp:1157)
    #08: _NS_InvokeByIndex (c:\work\mozilla-central\xpcom\reflect\xptcall\md\win32\xptcinvoke_asm_x86_msvc.asm:57)
  }
}
----------------------------------------------------------
Assignee: nobody → mantaroh
OS: Unspecified → Windows
Hardware: Unspecified → x86
Comment on attachment 8907416 [details]
Bug 1399336 - Memory leak of char16_t internal variables of widget/nsPrintOptionsImpl.cpp

https://reviewboard.mozilla.org/r/179102/#review184218
Attachment #8907416 - Flags: review?(m_kato) → review+
Comment on attachment 8907416 [details]
Bug 1399336 - Memory leak of char16_t internal variables of widget/nsPrintOptionsImpl.cpp

https://reviewboard.mozilla.org/r/179102/#review184218

Thanks!
Status: NEW → ASSIGNED
Pushed by mantaroh@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/f92907da4b68
Memory leak of char16_t internal variables of widget/nsPrintOptionsImpl.cpp r=m_kato
https://hg.mozilla.org/mozilla-central/rev/f92907da4b68
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: