Title: [122452] trunk/Source/WebKit2
Revision
122452
Author
[email protected]
Date
2012-07-12 06:39:22 -0700 (Thu, 12 Jul 2012)

Log Message

[EFL] [WK2] regression(r122411) Crashes in Ewk_View
https://bugs.webkit.org/show_bug.cgi?id=91068

Patch by Christophe Dumez <[email protected]> on 2012-07-12
Reviewed by Kentaro Hara.

Avoid using calloc() to allocate memory for structures
and use new operator instead. calloc() causes unwanted
behavior when allocing a structure which contains
non-pointer types (e.g. a HashMap) and leads to
crashes.

* UIProcess/API/efl/ewk_context.cpp:
(_Ewk_Context::_Ewk_Context):
* UIProcess/API/efl/ewk_intent.cpp:
(_Ewk_Intent):
(_Ewk_Intent::_Ewk_Intent):
(ewk_intent_unref):
(ewk_intent_new):
* UIProcess/API/efl/ewk_intent_service.cpp:
(_Ewk_Intent_Service):
(_Ewk_Intent_Service::_Ewk_Intent_Service):
(ewk_intent_service_unref):
(ewk_intent_service_new):
* UIProcess/API/efl/ewk_navigation_policy_decision.cpp:
(_Ewk_Navigation_Policy_Decision):
(_Ewk_Navigation_Policy_Decision::_Ewk_Navigation_Policy_Decision):
(ewk_navigation_policy_decision_free):
(ewk_navigation_policy_decision_new):
* UIProcess/API/efl/ewk_url_request.cpp:
(_Ewk_Url_Request):
(_Ewk_Url_Request::_Ewk_Url_Request):
(ewk_url_request_unref):
(ewk_url_request_new):
* UIProcess/API/efl/ewk_url_response.cpp:
(_Ewk_Url_Response):
(_Ewk_Url_Response::_Ewk_Url_Response):
(ewk_url_response_unref):
(ewk_url_response_new):
* UIProcess/API/efl/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_Ewk_View_Private_Data::_Ewk_View_Private_Data):
(_ewk_view_priv_new):
(_ewk_view_priv_del):
* UIProcess/API/efl/ewk_web_error.cpp:
(_Ewk_Web_Error):
(_Ewk_Web_Error::_Ewk_Web_Error):
(ewk_web_error_free):
(ewk_web_error_new):
* UIProcess/API/efl/ewk_web_resource.cpp:
(_Ewk_Web_Resource):
(_Ewk_Web_Resource::_Ewk_Web_Resource):
(ewk_web_resource_unref):
(ewk_web_resource_new):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122451 => 122452)


--- trunk/Source/WebKit2/ChangeLog	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-12 13:39:22 UTC (rev 122452)
@@ -1,3 +1,59 @@
+2012-07-12  Christophe Dumez  <[email protected]>
+
+        [EFL] [WK2] regression(r122411) Crashes in Ewk_View
+        https://bugs.webkit.org/show_bug.cgi?id=91068
+
+        Reviewed by Kentaro Hara.
+
+        Avoid using calloc() to allocate memory for structures
+        and use new operator instead. calloc() causes unwanted
+        behavior when allocing a structure which contains
+        non-pointer types (e.g. a HashMap) and leads to
+        crashes.
+
+        * UIProcess/API/efl/ewk_context.cpp:
+        (_Ewk_Context::_Ewk_Context):
+        * UIProcess/API/efl/ewk_intent.cpp:
+        (_Ewk_Intent):
+        (_Ewk_Intent::_Ewk_Intent):
+        (ewk_intent_unref):
+        (ewk_intent_new):
+        * UIProcess/API/efl/ewk_intent_service.cpp:
+        (_Ewk_Intent_Service):
+        (_Ewk_Intent_Service::_Ewk_Intent_Service):
+        (ewk_intent_service_unref):
+        (ewk_intent_service_new):
+        * UIProcess/API/efl/ewk_navigation_policy_decision.cpp:
+        (_Ewk_Navigation_Policy_Decision):
+        (_Ewk_Navigation_Policy_Decision::_Ewk_Navigation_Policy_Decision):
+        (ewk_navigation_policy_decision_free):
+        (ewk_navigation_policy_decision_new):
+        * UIProcess/API/efl/ewk_url_request.cpp:
+        (_Ewk_Url_Request):
+        (_Ewk_Url_Request::_Ewk_Url_Request):
+        (ewk_url_request_unref):
+        (ewk_url_request_new):
+        * UIProcess/API/efl/ewk_url_response.cpp:
+        (_Ewk_Url_Response):
+        (_Ewk_Url_Response::_Ewk_Url_Response):
+        (ewk_url_response_unref):
+        (ewk_url_response_new):
+        * UIProcess/API/efl/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_Ewk_View_Private_Data::_Ewk_View_Private_Data):
+        (_ewk_view_priv_new):
+        (_ewk_view_priv_del):
+        * UIProcess/API/efl/ewk_web_error.cpp:
+        (_Ewk_Web_Error):
+        (_Ewk_Web_Error::_Ewk_Web_Error):
+        (ewk_web_error_free):
+        (ewk_web_error_new):
+        * UIProcess/API/efl/ewk_web_resource.cpp:
+        (_Ewk_Web_Resource):
+        (_Ewk_Web_Resource::_Ewk_Web_Resource):
+        (ewk_web_resource_unref):
+        (ewk_web_resource_new):
+
 2012-07-11  Andras Becsi  <[email protected]>
 
         [Qt][WK2] ASSERT: "!m_viewportItem->isMoving()" in QtViewportHandler::flickMoveEnded()

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -35,9 +35,8 @@
 #endif
 
     _Ewk_Context(WKContextRef contextRef)
-    {
-        this->context = contextRef;
-    }
+        : context(contextRef)
+    { }
 };
 
 WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext)

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -50,6 +50,17 @@
     const char* action;
     const char* type;
     const char* service;
+
+    _Ewk_Intent(WKIntentDataRef intentRef)
+        : __ref(1)
+#if ENABLE(WEB_INTENTS)
+        , wkIntent(intentRef)
+#endif
+        , action(0)
+        , type(0)
+        , service(0)
+    {
+    }
 };
 
 #define EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent_, ...)    \
@@ -82,7 +93,7 @@
     eina_stringshare_del(intent->action);
     eina_stringshare_del(intent->type);
     eina_stringshare_del(intent->service);
-    free(intent);
+    delete intent;
 #endif
 }
 
@@ -192,11 +203,7 @@
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(intentData, 0);
 
-    Ewk_Intent* ewkIntent = static_cast<Ewk_Intent*>(calloc(1, sizeof(Ewk_Intent)));
-    ewkIntent->__ref = 1;
-    ewkIntent->wkIntent = intentData;
-
-    return ewkIntent;
+    return new Ewk_Intent(intentData);
 }
 
 WKIntentDataRef ewk_intent_WKIntentDataRef_get(const Ewk_Intent* intent)

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -50,6 +50,18 @@
     const char* href;
     const char* title;
     const char* disposition;
+
+    _Ewk_Intent_Service(WKIntentServiceInfoRef serviceRef)
+        : __ref(1)
+#if ENABLE(WEB_INTENTS_TAG)
+        , wkService(serviceRef)
+#endif
+        , action(0)
+        , type(0)
+        , href(0)
+        , title(0)
+        , disposition(0)
+    { }
 };
 
 #define EWK_INTENT_SERVICE_WK_GET_OR_RETURN(service, wkService_, ...) \
@@ -84,7 +96,7 @@
     eina_stringshare_del(service->href);
     eina_stringshare_del(service->title);
     eina_stringshare_del(service->disposition);
-    free(service);
+    delete service;
 #endif
 }
 
@@ -168,10 +180,6 @@
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(wkService, 0);
 
-    Ewk_Intent_Service* ewkIntentService = static_cast<Ewk_Intent_Service*>(calloc(1, sizeof(Ewk_Intent_Service)));
-    ewkIntentService->__ref = 1;
-    ewkIntentService->wkService = wkService;
-
-    return ewkIntentService;
+    return new Ewk_Intent_Service(wkService);
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -47,6 +47,16 @@
     Event_Modifier_Keys modifiers;
     Ewk_Url_Request* request;
     const char* frameName;
+
+    _Ewk_Navigation_Policy_Decision(WKFramePolicyListenerRef _listener, Ewk_Navigation_Type _navigationType, Event_Mouse_Button _mouseButton, Event_Modifier_Keys _modifiers, Ewk_Url_Request* _request, const char* _frameName)
+        : listener(_listener)
+        , actedUponByClient(false)
+        , navigationType(_navigationType)
+        , mouseButton(_mouseButton)
+        , modifiers(_modifiers)
+        , request(_request)
+        , frameName(eina_stringshare_add(_frameName))
+    { }
 };
 
 void ewk_navigation_policy_decision_free(Ewk_Navigation_Policy_Decision* decision)
@@ -59,7 +69,7 @@
 
     ewk_url_request_unref(decision->request);
     eina_stringshare_del(decision->frameName);
-    free(decision);
+    delete decision;
 }
 
 Ewk_Navigation_Type ewk_navigation_policy_navigation_type_get(const Ewk_Navigation_Policy_Decision* decision)
@@ -143,13 +153,10 @@
 
 Ewk_Navigation_Policy_Decision* ewk_navigation_policy_decision_new(WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, WKURLRequestRef request, const char* frameName, WKFramePolicyListenerRef listener)
 {
-    Ewk_Navigation_Policy_Decision* ewkPolicyDecision = static_cast<Ewk_Navigation_Policy_Decision*>(calloc(1, sizeof(Ewk_Navigation_Policy_Decision)));
-    ewkPolicyDecision->listener = listener;
-    ewkPolicyDecision->mouseButton = static_cast<Event_Mouse_Button>(mouseButton);
-    ewkPolicyDecision->modifiers = static_cast<Event_Modifier_Keys>(modifiers);
-    ewkPolicyDecision->navigationType = static_cast<Ewk_Navigation_Type>(navigationType);
-    ewkPolicyDecision->request = ewk_url_request_new(request);
-    ewkPolicyDecision->frameName = eina_stringshare_add(frameName);
-
-    return ewkPolicyDecision;
+    return new Ewk_Navigation_Policy_Decision(listener,
+                                              static_cast<Ewk_Navigation_Type>(navigationType),
+                                              static_cast<Event_Mouse_Button>(mouseButton),
+                                              static_cast<Event_Modifier_Keys>(modifiers),
+                                              ewk_url_request_new(request),
+                                              frameName);
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -48,6 +48,14 @@
     const char* url;
     const char* first_party;
     const char* http_method;
+
+    _Ewk_Url_Request(WKURLRequestRef requestRef)
+        : __ref(1)
+        , wkRequest(requestRef)
+        , url(0)
+        , first_party(0)
+        , http_method(0)
+    { }
 };
 
 #define EWK_URL_REQUEST_WK_GET_OR_RETURN(request, wkRequest_, ...)    \
@@ -77,7 +85,7 @@
     eina_stringshare_del(request->url);
     eina_stringshare_del(request->first_party);
     eina_stringshare_del(request->http_method);
-    free(request);
+    delete request;
 }
 
 const char* ewk_url_request_url_get(const Ewk_Url_Request* request)
@@ -119,9 +127,5 @@
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(wkUrlRequest, 0);
 
-    Ewk_Url_Request* ewkUrlRequest = static_cast<Ewk_Url_Request*>(calloc(1, sizeof(Ewk_Url_Request)));
-    ewkUrlRequest->__ref = 1;
-    ewkUrlRequest->wkRequest = wkUrlRequest;
-
-    return ewkUrlRequest;
+    return new Ewk_Url_Request(wkUrlRequest);
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -39,6 +39,13 @@
 
     const char* url;
     const char* mimeType;
+
+    _Ewk_Url_Response(const WebCore::ResourceResponse& _coreResponse)
+        : __ref(1)
+        , coreResponse(_coreResponse)
+        , url(0)
+        , mimeType(0)
+    { }
 };
 
 void ewk_url_response_ref(Ewk_Url_Response* response)
@@ -56,7 +63,7 @@
 
     eina_stringshare_del(response->url);
     eina_stringshare_del(response->mimeType);
-    free(response);
+    delete response;
 }
 
 const char* ewk_url_response_url_get(const Ewk_Url_Response* response)
@@ -92,9 +99,5 @@
  */
 Ewk_Url_Response* ewk_url_response_new(const WebCore::ResourceResponse& coreResponse)
 {
-    Ewk_Url_Response* ewkUrlResponse = static_cast<Ewk_Url_Response*>(calloc(1, sizeof(Ewk_Url_Response)));
-    ewkUrlResponse->__ref = 1;
-    ewkUrlResponse->coreResponse = coreResponse;
-
-    return ewkUrlResponse;
+    return new Ewk_Url_Response(coreResponse);
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -50,6 +50,11 @@
     const char* uri;
     const char* title;
     LoadingResourcesMap loadingResourcesMap;
+
+    _Ewk_View_Private_Data()
+        : uri(0)
+        , title(0)
+    { }
 };
 
 #define EWK_VIEW_TYPE_CHECK(ewkView, result)                                   \
@@ -260,8 +265,7 @@
 
 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
 {
-    Ewk_View_Private_Data* priv =
-        static_cast<Ewk_View_Private_Data*>(calloc(1, sizeof(Ewk_View_Private_Data)));
+    Ewk_View_Private_Data* priv = new Ewk_View_Private_Data;
     if (!priv) {
         EINA_LOG_CRIT("could not allocate Ewk_View_Private_Data");
         return 0;
@@ -278,7 +282,7 @@
     priv->pageClient = nullptr;
     eina_stringshare_del(priv->uri);
     eina_stringshare_del(priv->title);
-    free(priv);
+    delete priv;
 }
 
 static void _ewk_view_smart_add(Evas_Object* ewkView)

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -44,6 +44,12 @@
 
     const char* url;
     const char* description;
+
+    _Ewk_Web_Error(WKErrorRef errorRef)
+        : wkError(errorRef)
+        , url(0)
+        , description(0)
+    { }
 };
 
 #define EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError_, ...)    \
@@ -63,7 +69,7 @@
 
     eina_stringshare_del(error->url);
     eina_stringshare_del(error->description);
-    free(error);
+    delete error;
 }
 
 Ewk_Web_Error_Type ewk_web_error_type_get(const Ewk_Web_Error* error)
@@ -122,8 +128,5 @@
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0);
 
-    Ewk_Web_Error* ewkError = static_cast<Ewk_Web_Error*>(calloc(1, sizeof(Ewk_Web_Error)));
-    ewkError->wkError = error;
-
-    return ewkError;
+    return new Ewk_Web_Error(error);
 }

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_resource.cpp (122451 => 122452)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_resource.cpp	2012-07-12 13:32:42 UTC (rev 122451)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_resource.cpp	2012-07-12 13:39:22 UTC (rev 122452)
@@ -33,6 +33,12 @@
     unsigned int __ref; /**< the reference count of the object */
     CString url;
     bool isMainResource;
+
+    _Ewk_Web_Resource(const char* _url, bool _isMainResource)
+        : __ref(1)
+         , url(_url)
+        , isMainResource(_isMainResource)
+    { }
 };
 
 void ewk_web_resource_ref(Ewk_Web_Resource* resource)
@@ -49,7 +55,7 @@
     if (--resource->__ref)
         return;
 
-    free(resource);
+    delete resource;
 }
 
 const char* ewk_web_resource_url_get(const Ewk_Web_Resource* resource)
@@ -67,12 +73,7 @@
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
 
-    Ewk_Web_Resource* resource = static_cast<Ewk_Web_Resource*>(calloc(1, sizeof(Ewk_Web_Resource)));
-    resource->url = ""
-    resource->isMainResource = isMainResource;
-    resource->__ref = 1;
-
-    return resource;
+    return new Ewk_Web_Resource(url, isMainResource);
 }
 
 Eina_Bool ewk_web_resource_main_resource_get(const Ewk_Web_Resource* resource)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to