Fix memory leak in connection_create when libnet init fails 63/237063/2 accepted/tizen/unified/20200717.124737 submit/tizen/20200716.045801
authorNishant Chaprana <n.chaprana@samsung.com>
Wed, 24 Jun 2020 19:42:57 +0000 (01:12 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Wed, 24 Jun 2020 19:43:51 +0000 (01:13 +0530)
Change-Id: I90d134ca5bae5be30d4943079de3d33f6cf6d0bd
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/capi-network-connection.spec
src/connection.c

index 7cb4339..fd19d28 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-connection
 Summary:       Network Connection library in TIZEN C API
-Version:       1.0.117
+Version:       1.0.118
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index a00868f..8b9f3a7 100755 (executable)
@@ -169,10 +169,16 @@ EXPORT_API int connection_create(connection_h *connection)
        rv = _connection_libnet_init(*connection);
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               g_free(*connection);
+               *connection = NULL;
+
                CONN_UNLOCK; //LCOV_EXCL_LINE
                return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to create connection[%d]", rv); //LCOV_EXCL_LINE
+               g_free(*connection);
+               *connection = NULL;
+
                CONN_UNLOCK; //LCOV_EXCL_LINE
                return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }