Title: [158500] trunk/Source/WebKit2
- Revision
- 158500
- Author
- m...@apple.com
- Date
- 2013-11-02 14:56:07 -0700 (Sat, 02 Nov 2013)
Log Message
[Cocoa] Wrappers mishandle NULL values in arrays and dictionaries
https://bugs.webkit.org/show_bug.cgi?id=123671
Reviewed by Darin Adler.
* Shared/Cocoa/WKNSArray.mm:
(-[WKNSArray objectAtIndex:]): Represent a NULL object as NSNull.
* Shared/Cocoa/WKNSDictionary.mm:
(-[WKNSDictionary objectForKey:]): Represent a NULL value as NSNull.
* Shared/ImmutableDictionary.h:
(WebKit::ImmutableDictionary::get): Added this overload that returns whether the key exists.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (158499 => 158500)
--- trunk/Source/WebKit2/ChangeLog 2013-11-02 21:47:46 UTC (rev 158499)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-02 21:56:07 UTC (rev 158500)
@@ -1,5 +1,19 @@
2013-11-02 Dan Bernstein <m...@apple.com>
+ [Cocoa] Wrappers mishandle NULL values in arrays and dictionaries
+ https://bugs.webkit.org/show_bug.cgi?id=123671
+
+ Reviewed by Darin Adler.
+
+ * Shared/Cocoa/WKNSArray.mm:
+ (-[WKNSArray objectAtIndex:]): Represent a NULL object as NSNull.
+ * Shared/Cocoa/WKNSDictionary.mm:
+ (-[WKNSDictionary objectForKey:]): Represent a NULL value as NSNull.
+ * Shared/ImmutableDictionary.h:
+ (WebKit::ImmutableDictionary::get): Added this overload that returns whether the key exists.
+
+2013-11-02 Dan Bernstein <m...@apple.com>
+
Fixed release builds.
* Shared/Cocoa/WKNSDictionary.mm:
Modified: trunk/Source/WebKit2/Shared/Cocoa/WKNSArray.mm (158499 => 158500)
--- trunk/Source/WebKit2/Shared/Cocoa/WKNSArray.mm 2013-11-02 21:47:46 UTC (rev 158499)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSArray.mm 2013-11-02 21:56:07 UTC (rev 158500)
@@ -50,7 +50,8 @@
- (id)objectAtIndex:(NSUInteger)i
{
- return reinterpret_cast<ImmutableArray*>(&_array)->at(i)->wrapper();
+ APIObject* object = reinterpret_cast<ImmutableArray*>(&_array)->at(i);
+ return object ? object->wrapper() : [NSNull null];
}
#pragma mark NSCopying protocol implementation
Modified: trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm (158499 => 158500)
--- trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm 2013-11-02 21:47:46 UTC (rev 158499)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm 2013-11-02 21:56:07 UTC (rev 158500)
@@ -61,10 +61,12 @@
if (![key isKindOfClass:[NSString class]])
return nil;
- if (APIObject* value = reinterpret_cast<ImmutableDictionary*>(&_dictionary)->get((NSString *)key))
- return value->wrapper();
+ bool exists;
+ APIObject* value = reinterpret_cast<ImmutableDictionary*>(&_dictionary)->get((NSString *)key, exists);
+ if (!exists)
+ return nil;
- return nil;
+ return value ? value->wrapper() : [NSNull null];
}
- (NSEnumerator *)keyEnumerator
Modified: trunk/Source/WebKit2/Shared/ImmutableDictionary.h (158499 => 158500)
--- trunk/Source/WebKit2/Shared/ImmutableDictionary.h 2013-11-02 21:47:46 UTC (rev 158499)
+++ trunk/Source/WebKit2/Shared/ImmutableDictionary.h 2013-11-02 21:56:07 UTC (rev 158500)
@@ -73,6 +73,13 @@
return m_map.get(key);
}
+ APIObject* get(const String& key, bool& exists)
+ {
+ const auto& it = m_map.find(key);
+ exists = it != m_map.end();
+ return it->value.get();
+ }
+
PassRefPtr<ImmutableArray> keys() const;
size_t size() { return m_map.size(); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes