Fix static analysis tool checker 92/60892/1
authorYu Jiung <jiung.yu@samsung.com>
Thu, 3 Mar 2016 00:51:47 +0000 (09:51 +0900)
committerYu Jiung <jiung.yu@samsung.com>
Thu, 3 Mar 2016 00:51:47 +0000 (09:51 +0900)
Change-Id: I330dcb962c1ad435fd099abb10edce374e68deb8

src/ssdp/ssdp.c
test/dns-sd-test.c
test/ssdp-test.c

index f348db3..23b4c04 100644 (file)
@@ -307,6 +307,7 @@ __ssdp_res_available_cb (GSSDPResourceBrowser *resource_browser,
        if (found_service != NULL &&
                        g_strcmp0(found_service->usn, usn) == 0) {
                SSDP_LOGD("Duplicated service!");
+               g_free(temp_url);
                __SSDP_LOG_FUNC_EXIT__;
                return;
        }
@@ -314,6 +315,7 @@ __ssdp_res_available_cb (GSSDPResourceBrowser *resource_browser,
        found_service = (ssdp_service_s *)g_try_malloc0(sizeof(ssdp_service_s));
        if (!found_service) {
                SSDP_LOGE("Failed to get memory for ssdp service structure");
+               g_free(temp_url);
                __SSDP_LOG_FUNC_EXIT__;
                return;
        }
@@ -364,6 +366,11 @@ __ssdp_res_unavailable_cb (GSSDPResourceBrowser *resource_browser,
 
        SSDP_LOGD("resource unavailable\n  USN: %s\n", usn);
 
+       if (browser->found_cb) {
+               browser->found_cb(found_service->service_handler,
+                               SSDP_SERVICE_STATE_UNAVAILABLE, browser->cb_user_data);
+       }
+
        g_hash_table_remove(g_found_ssdp_services, usn);
        g_free(found_service->target);
        g_free(found_service->usn);
@@ -372,11 +379,6 @@ __ssdp_res_unavailable_cb (GSSDPResourceBrowser *resource_browser,
 
        SSDP_LOGD("Hash tbl size [%d]", g_hash_table_size(g_found_ssdp_services));
 
-       if (browser->found_cb) {
-               browser->found_cb(found_service->service_handler,
-                               SSDP_SERVICE_STATE_UNAVAILABLE, browser->cb_user_data);
-       }
-
        __SSDP_LOG_FUNC_EXIT__;
        return;
 }
index 363739b..2ddbb29 100644 (file)
@@ -25,7 +25,7 @@ static bool test_get_user_string(const char *msg, char *buf, int buf_size)
                if (i == 0 && c == '\n')
                        continue;
 
-               if (c == '\n')
+               if (c == '\n' || c == EOF)
                        break;
 
                buf[i++] = c;
@@ -50,7 +50,7 @@ static bool test_get_user_bytes(const char *msg, char *buf, int buf_size)
                if (i == 0 && c == '\n')
                        continue;
 
-               if (c == '\n')
+               if (c == '\n' || c == EOF)
                        break;
 
                buf[i++] = c;
index bc863a3..7f3988f 100644 (file)
@@ -94,7 +94,7 @@ int test_ssdp_create_service()
        ssdp_service_h serv_id;
 
        printf("\nEnter target: (Example : upnp:rootdevice)");
-       if(scanf("%ms", &target) < 1)
+       if(scanf("%255ms", &target) < 1)
                return -1;
 
 
@@ -146,7 +146,7 @@ int test_ssdp_set_usn()
                return -1;
 
        printf("\nEnter usn: (Example : uuid:1234abcd-12ab-12ab-12ab-1234567abc12::upnp:rootdevice)");
-       if(scanf("%ms", &usn) < 1)
+       if(scanf("%255ms", &usn) < 1)
                return -1;
 
        rv = ssdp_service_set_usn(serv_id, usn);
@@ -174,7 +174,7 @@ int test_ssdp_set_url()
                return -1;
 
        printf("\nEnter url: (Example : http://192.168.0.110/)");
-       if(scanf("%ms", &url) < 1)
+       if(scanf("%255ms", &url) < 1)
                return -1;
 
        rv = ssdp_service_set_url(serv_id, url);
@@ -337,7 +337,7 @@ int test_ssdp_service_browse()
        char *target = NULL;
 
        printf("\nEnter target: (Example : upnp:rootdevice)");
-       if(scanf("%ms", &target) < 1)
+       if(scanf("%255ms", &target) < 1)
                return -1;
 
        rv = ssdp_start_browsing_service(target, &browser_id, &test_found_cb, NULL);