Changeset 20357 in webkit
- Timestamp:
- Mar 20, 2007 10:39:57 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r20355 r20357 1 2007-03-20 Brady Eidson <beidson@apple.com> 2 3 Reviewed by Anders 4 5 <rdar://problem/5073391> and http://bugs.webkit.org/show_bug.cgi?id=13137 6 7 Crash in IconDatabase when private browsing is enabled. 8 9 The problem was caused by http://trac.webkit.org/projects/webkit/changeset/20182 10 which changed many uses of char[] and Vector<char> to SharedBuffer. The patch 11 tended to literally replace a Vector<char> with RefPtr<SharedBuffers> but forgot 12 to enforce the concept that Vector<char>'s always exist, whereas RefPtr<SharedBuffers> 13 can be null. This led to derefs. 14 15 I took the opportunity to rework the iconDB functions to live in a SharedBuffer 16 world, as that didn't exist when they were originally written - now they just return 17 SharedBuffers instead of taking a Vector<char>& as a parameter 18 19 * loader/icon/IconDatabase.cpp: 20 (WebCore::IconDatabase::imageDataForIconURL): Return a SharedBuffer 21 (WebCore::IconDatabase::iconForPageURL): Null check the SharedBuffer before asking 22 it if it's empty 23 (WebCore::IconDatabase::imageDataForIconURLQuery): Return a new SharedBuffer 24 25 * loader/icon/IconDatabase.h: Return SharedBuffer's instead of taking Vector<char>&'s 26 1 27 2007-03-20 Adam Roben <aroben@apple.com> 2 28 -
trunk/WebCore/loader/icon/IconDatabase.cpp
r20243 r20357 325 325 } 326 326 327 void IconDatabase::imageDataForIconURL(const String& iconURL, PassRefPtr<SharedBuffer> result)327 PassRefPtr<SharedBuffer> IconDatabase::imageDataForIconURL(const String& iconURL) 328 328 { 329 329 // If private browsing is enabled, we'll check there first as the most up-to-date data for an icon will be there 330 330 if (m_privateBrowsingEnabled) { 331 imageDataForIconURLQuery(m_privateBrowsingDB, iconURL, result);332 if ( !result->isEmpty())333 return ;331 RefPtr<SharedBuffer> result = imageDataForIconURLQuery(m_privateBrowsingDB, iconURL); 332 if (result && !result->isEmpty()) 333 return result.release(); 334 334 } 335 335 336 336 // It wasn't found there, so lets check the main tables 337 imageDataForIconURLQuery(m_mainDB, iconURL, result);337 return imageDataForIconURLQuery(m_mainDB, iconURL); 338 338 } 339 339 … … 375 375 // we'll read in that image data now 376 376 if (icon->imageDataStatus() == ImageDataStatusUnknown) { 377 RefPtr<SharedBuffer> data = new SharedBuffer(); 378 imageDataForIconURL(iconURL, data.get()); 377 RefPtr<SharedBuffer> data = imageDataForIconURL(iconURL); 379 378 icon->setImageData(data.get()); 380 379 } … … 954 953 } 955 954 956 void IconDatabase::imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, PassRefPtr<SharedBuffer> imageData) 957 { 955 PassRefPtr<SharedBuffer> IconDatabase::imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL) 956 { 957 RefPtr<SharedBuffer> imageData; 958 958 959 readySQLStatement(m_imageDataForIconURLStatement, db, "SELECT Icon.data FROM Icon WHERE Icon.url = (?);"); 959 960 m_imageDataForIconURLStatement->bindText16(1, iconURL, false); 960 961 961 962 int result = m_imageDataForIconURLStatement->step(); 962 imageData->clear();963 963 if (result == SQLResultRow) { 964 964 Vector<char> data; 965 965 m_imageDataForIconURLStatement->getColumnBlobAsVector(0, data); 966 imageData = new SharedBuffer; 966 967 imageData->append(data.data(), data.size()); 967 968 } else if (result != SQLResultDone) … … 969 970 970 971 m_imageDataForIconURLStatement->reset(); 972 973 return imageData.release(); 971 974 } 972 975 -
trunk/WebCore/loader/icon/IconDatabase.h
r20182 r20357 123 123 124 124 // Returns the image data for the given IconURL, checking both databases if necessary 125 void imageDataForIconURL(const String& iconURL, PassRefPtr<SharedBuffer> result);125 PassRefPtr<SharedBuffer> imageDataForIconURL(const String& iconURL); 126 126 127 127 // Retains an iconURL, bringing it back from the brink if it was pending deletion … … 163 163 164 164 // Query - Returns the image data from the given database for the given IconURL 165 void imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL, PassRefPtr<SharedBuffer> result);165 PassRefPtr<SharedBuffer> imageDataForIconURLQuery(SQLDatabase& db, const String& iconURL); 166 166 SQLStatement* m_imageDataForIconURLStatement; 167 167
Note: See TracChangeset
for help on using the changeset viewer.