Closed Bug 257803 Opened 20 years ago Closed 20 years ago

Possible RegistryKey Leak in nsWindowsShellService

Categories

(Toolkit :: Startup and Profile System, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: henrik, Assigned: rOmAz)

Details

(Whiteboard: [good first bug])

Attachments

(3 files)

Running my Inspector it found a possible RegKey leak.

Will attach a stack trace showing where it is allocated, but apperently never 
deallocated (missing RegKeyClose)
Seems like a missing RegKeyClose at bottom of method.
Requesting block. 

* It is a leak (although minor) 
* Has stack trace pinpointing the problem area
* Has AFAIK a easy fix. (One missing RegKeyClose)
* Urban legends among trolls is that Firefox leaks, lets not give them ammo

note:possibly same error in OpenUserKeyForWriting
Flags: blocking-aviary1.0?
Version: unspecified → Trunk
Assignee: bsmedberg → bugs
Keywords: helpwanted
Whiteboard: [good first bug]
from msdn.microsoft.com: "The handle for a specified key should not be used
after it has been closed, because it will no longer be valid. Key handles
should not be left open any longer than necessary."

Most functions in nsWindowsShellService.cpp call RegOpenKeyEx without closing
it. The patch fixes the problem by adding RegCloseKey in all functions in that
file.

-rOmAz
Attachment #159326 - Flags: superreview?(bryner)
Attachment #159326 - Flags: review?(jshin)
-> rOmAz
Assignee: bugs → rOmAz
Comment on attachment 159326 [details] [diff] [review]
adds calls to RegCloseKey in missing places

r=jshin

Thanks for fixing it.

Perhaps, we have to fix mozilla as well.
Attachment #159326 - Flags: review?(jshin) → review+
Flags: blocking-aviary1.0? → blocking-aviary1.0-
Mike, want to review this and check in?
Comment on attachment 159326 [details] [diff] [review]
adds calls to RegCloseKey in missing places

r=me (not really SR, but I don't feel like bugspamming people to make the r=me
look right.  Thanks for the patch!
Attachment #159326 - Flags: superreview?(bryner) → superreview+
Whiteboard: [good first bug] → [good first bug] checkin-needed
Checking in browser/components/shell/src/nsWindowsShellService.cpp;
/cvsroot/mozilla/browser/components/shell/src/nsWindowsShellService.cpp,v  <--
nsWindowsShellService.cpp
new revision: 1.12; previous revision: 1.11
done
Status: NEW → RESOLVED
Closed: 20 years ago
Keywords: helpwanted
Resolution: --- → FIXED
Whiteboard: [good first bug] checkin-needed → [good first bug]
Comment on attachment 159326 [details] [diff] [review]
adds calls to RegCloseKey in missing places

Casing issue...

>Index: browser/components/shell/src/nsWindowsShellService.cpp
>===================================================================

>+      ::RegCloseKey(theKey);

This is the right


>@@ -581,6 +593,9 @@
>   if (REG_FAILED(result) || strcmp(buf, aValue) != 0)
>     ::RegSetValueEx(theKey, aValueName, 0, REG_SZ, 
>                     (LPBYTE)aValue, nsDependentCString(aValue).Length());
>+  
>+  // Close the key we opened.
>+  ::RegClosekey(theKey);

RegClose*K*ey
Comment on attachment 171448 [details] [diff] [review]
Bustage fix

checked in by timeless
(In reply to comment #5)
> (From update of attachment 159326 [details] [diff] [review] [edit])
> r=jshin
> 
> Thanks for fixing it.
> 
> Perhaps, we have to fix mozilla as well. 
> 
Was this just a Firefox fix? If so, WILL it go into Mozilla as well?
> Was this just a Firefox fix? 

Yes.

> If so, WILL it go into Mozilla as well?

The fix was to Firefox-only code.  If you find code in Mozilla that has similar
issues, please file a bug on it.
Status: RESOLVED → VERIFIED
Product: Firefox → Toolkit
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: