Closed Bug 999072 Opened 11 years ago Closed 11 years ago

MediaManager GetCharPref("media.video_loopback_dev") leaks strings in DEBUG build

Categories

(Core :: WebRTC: Audio/Video, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: jib, Assigned: ted)

References

Details

Attachments

(1 file)

From http://hg.mozilla.org/mozilla-central/rev/622e6c1191eb : > + char* loopbackAudioDevice = nullptr; > + char* loopbackVideoDevice = nullptr; > + nsresult rv; > +#ifdef DEBUG > + // Check if the preference for using loopback devices is enabled. > + nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv); > + if (NS_SUCCEEDED(rv)) { > + nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs); > + if (branch) { > + branch->GetCharPref("media.audio_loopback_dev", &loopbackAudioDevice); > + branch->GetCharPref("media.video_loopback_dev", &loopbackVideoDevice); > + } > + } > +#endif GetCharPref returns an NS_strdup() which is never released (twice here per call). Should use getter_Copies. It only leaks if you set one or both of the loopback values in about:config - they aren't normally set - and only in DEBUG.
This fixes the leak by way of switching to Preferences::GetCString, and also enables this code in non-debug builds since I want to use it for bug 815002.
Attachment #8416491 - Flags: review?(rjesup)
Assignee: nobody → ted
Status: NEW → ASSIGNED
Blocks: 815002
Attachment #8416491 - Flags: review?(rjesup) → review+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: