[EFL][WK2] Crash when passing NULL instead of ewk_view instance
authorryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Oct 2012 11:57:47 +0000 (11:57 +0000)
committerryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Oct 2012 11:57:47 +0000 (11:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=100078

Reviewed by Gyuyoung Kim.

Although applications should pass valid ewk_view to call ewk_view_XXX,
ewk_view_XXX should not be crashed.

* UIProcess/API/efl/ewk_view.cpp:
Checked null and early exited from EWK_VIEW_TYPE_CHECK if error occured.
* UIProcess/API/efl/tests/test_ewk2_view.cpp: Added test case.
(TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@132336 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp

index 130a34b..b31d3a7 100644 (file)
@@ -1,3 +1,18 @@
+2012-10-24  Ryuan Choi  <ryuan.choi@gmail.com>
+
+        [EFL][WK2] Crash when passing NULL instead of ewk_view instance
+        https://bugs.webkit.org/show_bug.cgi?id=100078
+
+        Reviewed by Gyuyoung Kim.
+
+        Although applications should pass valid ewk_view to call ewk_view_XXX,
+        ewk_view_XXX should not be crashed.
+
+        * UIProcess/API/efl/ewk_view.cpp:
+        Checked null and early exited from EWK_VIEW_TYPE_CHECK if error occured.
+        * UIProcess/API/efl/tests/test_ewk2_view.cpp: Added test case.
+        (TEST_F):
+
 2012-10-24  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL][WK2] Make find and form clients C++ classes
index 472a679..bd0e738 100644 (file)
@@ -200,6 +200,11 @@ struct Ewk_View_Private_Data {
 #define EWK_VIEW_TYPE_CHECK(ewkView, result)                                   \
     bool result = true;                                                        \
     do {                                                                       \
+        if (!ewkView) {                                                        \
+            EINA_LOG_CRIT("null is not a ewk_view");                           \
+            result = false;                                                    \
+            break;                                                             \
+        }                                                                      \
         const char* _tmp_otype = evas_object_type_get(ewkView);                \
         const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView);       \
         if (EINA_UNLIKELY(!_tmp_s)) {                                          \
@@ -207,6 +212,7 @@ struct Ewk_View_Private_Data {
                 ("%p (%s) is not a smart object!",                             \
                  ewkView, _tmp_otype ? _tmp_otype : "(null)");                 \
             result = false;                                                    \
+            break;                                                             \
         }                                                                      \
         const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s);        \
         if (EINA_UNLIKELY(!_tmp_sc)) {                                         \
@@ -214,6 +220,7 @@ struct Ewk_View_Private_Data {
                 ("%p (%s) is not a smart object!",                             \
                  ewkView, _tmp_otype ? _tmp_otype : "(null)");                 \
             result = false;                                                    \
+            break;                                                             \
         }                                                                      \
         if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) {               \
             EINA_LOG_CRIT                                                      \
index d4bb70f..11affd9 100644 (file)
@@ -38,6 +38,14 @@ using namespace EWK2UnitTest;
 extern EWK2UnitTestEnvironment* environment;
 bool fullScreenCallbackCalled;
 
+TEST_F(EWK2UnitTestBase, ewk_view_type_check)
+{
+    ASSERT_FALSE(ewk_view_context_get(0));
+
+    Evas_Object* rectangle = evas_object_rectangle_add(canvas());
+    ASSERT_FALSE(ewk_view_url_set(rectangle, 0));
+}
+
 static void onLoadFinishedForRedirection(void* userData, Evas_Object*, void*)
 {
     int* countLoadFinished = static_cast<int*>(userData);