Title: [275131] trunk/Source/WebKitLegacy/mac
Revision
275131
Author
[email protected]
Date
2021-03-26 21:47:00 -0700 (Fri, 26 Mar 2021)

Log Message

WebFeature class fails to copy/retain its instance variables
<https://webkit.org/b/223823>

Reviewed by Sam Weinig.

* WebView/WebFeature.m:
(-[WebFeature initWithKey:preferenceKey:name:details:defaultValue:hidden:]):
- Copy (and thereby retain) instance variables, fulfilling the
  promise of its @property declarations and preventing
  use-after-release issues.
(-[WebFeature dealloc]): Add.
- Release the instance variables copied in the constructor.

Modified Paths

Diff

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (275130 => 275131)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-03-27 04:24:21 UTC (rev 275130)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-03-27 04:47:00 UTC (rev 275131)
@@ -1,3 +1,18 @@
+2021-03-26  David Kilzer  <[email protected]>
+
+        WebFeature class fails to copy/retain its instance variables
+        <https://webkit.org/b/223823>
+
+        Reviewed by Sam Weinig.
+
+        * WebView/WebFeature.m:
+        (-[WebFeature initWithKey:preferenceKey:name:details:defaultValue:hidden:]):
+        - Copy (and thereby retain) instance variables, fulfilling the
+          promise of its @property declarations and preventing
+          use-after-release issues.
+        (-[WebFeature dealloc]): Add.
+        - Release the instance variables copied in the constructor.
+
 2021-03-26  Jessie Berlin  <[email protected]>
 
         Update the BEFORE/SINCE, SYSTEM_VERSION_PREFIX, and MACOSX_DEPLOYMENT_TARGET flags

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFeature.m (275130 => 275131)


--- trunk/Source/WebKitLegacy/mac/WebView/WebFeature.m	2021-03-27 04:24:21 UTC (rev 275130)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFeature.m	2021-03-27 04:47:00 UTC (rev 275131)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,15 +32,24 @@
     if (!(self = [super init]))
         return nil;
 
-    _key = key;
-    _preferenceKey = preferenceKey;
-    _name = name;
-    _details = details;
+    _key = [key copy];
+    _preferenceKey = [preferenceKey copy];
+    _name = [name copy];
+    _details = [details copy];
     _defaultValue = defaultValue;
     _hidden = hidden;
     return self;
 }
 
+- (void)dealloc
+{
+    [_key release];
+    [_preferenceKey release];
+    [_name release];
+    [_details release];
+    [super dealloc];
+}
+
 - (NSString *)description
 {
     return [NSString stringWithFormat:@"<%@: %p; name = %@; key = %@; defaultValue = %@>", NSStringFromClass(self.class), self, self.name, self.key, self.defaultValue ? @"on" : @"off"];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to