Changeset 243608 in webkit
- Timestamp:
- Mar 28, 2019, 10:50:18 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestResources.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r243606 r243608 1 2019-03-28 Michael Catanzaro <mcatanzaro@igalia.com> 2 3 [WPE][GTK] webkit_web_resource_get_data_finish can return NULL without setting error 4 https://bugs.webkit.org/show_bug.cgi?id=186276 5 6 Reviewed by Carlos Garcia Campos. 7 8 Currently it's possible for webkit_web_resource_get_data_finish() to return NULL without 9 setting the error parameter. This is illegal because it is an API guarantee (and a GObject 10 convention) that if an error parameter exists, it should be set whenever a function call 11 returns NULL. Epiphany correctly dereferences the error in this case without checking if it 12 is NULL, because it knows it does not have to, and crashes. Fix this. We'll return a byte 13 array of length 1 containing a NUL character. This isn't great, but there's not really any 14 better solution without deprecating the API or returning an error code to indicate an empty 15 resource, and it at least fixes the Epiphany crash. 16 17 This does not fix bug #186276, in which this function incorrectly returns no data when it 18 ought to. But that is a different bug. Now, at least we won't crash when no data is 19 available. 20 21 * UIProcess/API/glib/WebKitWebResource.cpp: 22 (resourceDataCallback): 23 1 24 2019-03-28 Daniel Bates <dabates@apple.com> 2 25 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp
r222735 r243608 352 352 ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); 353 353 data->webData = wkData; 354 if (!wkData->bytes()) 355 data->webData = API::Data::create(reinterpret_cast<const unsigned char*>(""), 1); 354 356 g_task_return_boolean(task, TRUE); 355 357 } -
trunk/Tools/ChangeLog
r243567 r243608 1 2019-03-28 Michael Catanzaro <mcatanzaro@igalia.com> 2 3 [WPE][GTK] webkit_web_resource_get_data_finish can return NULL without setting error 4 https://bugs.webkit.org/show_bug.cgi?id=186276 5 6 Reviewed by Carlos Garcia Campos. 7 8 * TestWebKitAPI/Tests/WebKitGLib/TestResources.cpp: 9 (webViewLoadChanged): 10 (testWebResourceGetDataError): 11 (testWebResourceGetDataEmpty): 12 (beforeAll): 13 (webViewloadChanged): Deleted. 14 1 15 2019-03-27 Andy Estes <aestes@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestResources.cpp
r239772 r243608 537 537 } 538 538 539 static void webView loadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, GMainLoop* mainLoop)539 static void webViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, GMainLoop* mainLoop) 540 540 { 541 541 if (loadEvent != WEBKIT_LOAD_FINISHED) 542 542 return; 543 g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(webView loadChanged), mainLoop);543 g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(webViewLoadChanged), mainLoop); 544 544 g_main_loop_quit(mainLoop); 545 545 } … … 550 550 GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(Test::createWebView(test->m_webContext.get())); 551 551 webkit_web_view_load_html(webView.get(), "<html></html>", nullptr); 552 g_signal_connect(webView.get(), "load-changed", G_CALLBACK(webView loadChanged), mainLoop.get());552 g_signal_connect(webView.get(), "load-changed", G_CALLBACK(webViewLoadChanged), mainLoop.get()); 553 553 g_main_loop_run(mainLoop.get()); 554 554 … … 564 564 }, mainLoop.get()); 565 565 webView = nullptr; 566 g_main_loop_run(mainLoop.get()); 567 } 568 569 static void testWebResourceGetDataEmpty(Test* test, gconstpointer) 570 { 571 GRefPtr<GMainLoop> mainLoop = adoptGRef(g_main_loop_new(nullptr, FALSE)); 572 GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(Test::createWebView(test->m_webContext.get())); 573 webkit_web_view_load_html(webView.get(), "", nullptr); 574 g_signal_connect(webView.get(), "load-changed", G_CALLBACK(webViewLoadChanged), mainLoop.get()); 575 g_main_loop_run(mainLoop.get()); 576 577 auto* resource = webkit_web_view_get_main_resource(webView.get()); 578 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(resource)); 579 webkit_web_resource_get_data(resource, nullptr, [](GObject* source, GAsyncResult* result, gpointer userData) { 580 size_t dataSize; 581 GUniqueOutPtr<GError> error; 582 auto* data = webkit_web_resource_get_data_finish(WEBKIT_WEB_RESOURCE(source), result, &dataSize, &error.outPtr()); 583 g_assert_nonnull(data); 584 g_assert_cmpuint(dataSize, ==, 1); 585 g_assert_cmpint(data[0], ==, '\0'); 586 g_assert_no_error(error.get()); 587 g_main_loop_quit(static_cast<GMainLoop*>(userData)); 588 }, mainLoop.get()); 566 589 g_main_loop_run(mainLoop.get()); 567 590 } … … 898 921 ResourcesTest::add("WebKitWebResource", "get-data", testWebResourceGetData); 899 922 Test::add("WebKitWebResource", "get-data-error", testWebResourceGetDataError); 923 Test::add("WebKitWebResource", "get-data-empty", testWebResourceGetDataEmpty); 900 924 SingleResourceLoadTest::add("WebKitWebView", "history-cache", testWebViewResourcesHistoryCache); 901 925 SendRequestTest::add("WebKitWebPage", "send-request", testWebResourceSendRequest);
Note:
See TracChangeset
for help on using the changeset viewer.