You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2020/03/27 18:05:00 UTC
[celix] branch develop updated: Memory leak fixes (#177)
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/develop by this push:
new e0ca87a Memory leak fixes (#177)
e0ca87a is described below
commit e0ca87a2347b56742d68f9527e0f967ef2ae928b
Author: Michael de Lang <ki...@gmail.com>
AuthorDate: Fri Mar 27 18:04:50 2020 +0000
Memory leak fixes (#177)
* Fix some memory leaks
---
.../src/pubsub_websocket_topic_receiver.c | 2 +-
libs/dfi/include/dyn_type.h | 2 +-
libs/dfi/src/dyn_type.c | 2 +-
libs/dfi/test/dyn_function_tests.cpp | 1 +
libs/utils/private/test/version_range_test.cpp | 11 ++++++-----
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_receiver.c b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_receiver.c
index 5014015..47b25bc 100644
--- a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_receiver.c
+++ b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_receiver.c
@@ -518,7 +518,6 @@ static inline void processMsg(pubsub_websocket_topic_receiver_t *receiver, const
}
}
celixThreadMutex_unlock(&receiver->subscribers.mutex);
- free((void *) hdr.id);
free((void *) payload);
} else {
L_WARN("[PSA_WEBSOCKET_TR] Received unsupported message: "
@@ -527,6 +526,7 @@ static inline void processMsg(pubsub_websocket_topic_receiver_t *receiver, const
json_integer_value(jsMajor), json_integer_value(jsMinor),
json_integer_value(jsSeqNr), (jsData ? "TRUE" : "FALSE"));
}
+ json_decref(jsMsg);
} else {
L_WARN("[PSA_WEBSOCKET_TR] Failed to load websocket JSON message, error line: %d, error message: %s", error.line, error.text);
return;
diff --git a/libs/dfi/include/dyn_type.h b/libs/dfi/include/dyn_type.h
index 53dbdf8..a757c9f 100644
--- a/libs/dfi/include/dyn_type.h
+++ b/libs/dfi/include/dyn_type.h
@@ -215,7 +215,7 @@ int dynType_type(dyn_type *type);
* @param type The dyn type
* @return The descriptor of the dyn type.
*/
-int dynType_descriptorType(dyn_type *type);
+char dynType_descriptorType(dyn_type *type);
/**
* Get the dyn type meta information for the provided name.
diff --git a/libs/dfi/src/dyn_type.c b/libs/dfi/src/dyn_type.c
index 4f93fb9..36ae7dc 100644
--- a/libs/dfi/src/dyn_type.c
+++ b/libs/dfi/src/dyn_type.c
@@ -806,7 +806,7 @@ void dynType_simple_setValue(dyn_type *type, void *inst, void *in) {
memcpy(inst, in, size);
}
-int dynType_descriptorType(dyn_type *type) {
+char dynType_descriptorType(dyn_type *type) {
return type->descriptor;
}
diff --git a/libs/dfi/test/dyn_function_tests.cpp b/libs/dfi/test/dyn_function_tests.cpp
index 3073a98..2ac0f58 100644
--- a/libs/dfi/test/dyn_function_tests.cpp
+++ b/libs/dfi/test/dyn_function_tests.cpp
@@ -248,6 +248,7 @@ extern "C" {
CHECK_EQUAL(0, rc);
dynFunction_destroy(dynFunc);
+ free(a2);
}
diff --git a/libs/utils/private/test/version_range_test.cpp b/libs/utils/private/test/version_range_test.cpp
index eb1c374..796d916 100644
--- a/libs/utils/private/test/version_range_test.cpp
+++ b/libs/utils/private/test/version_range_test.cpp
@@ -145,11 +145,6 @@ TEST(version_range, isInRange) {
low->minor = 2;
low->micro = 3;
- version_pt high = (version_pt) calloc(1, sizeof(*high));
- high->major = 1;
- high->minor = 2;
- high->micro = 3;
-
LONGS_EQUAL(CELIX_SUCCESS, versionRange_createVersionRange(low, true, NULL, true, &range));
LONGS_EQUAL(CELIX_SUCCESS, versionRange_isInRange(range, version, &result));
LONGS_EQUAL(true, result);
@@ -242,6 +237,7 @@ TEST(version_range, parse) {
LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, versionRange_parse(version, &range));
free(version);
+
free(high);
free(low);
}
@@ -266,6 +262,7 @@ TEST(version_range, createLdapFilterInclusiveBoth) {
STRCMP_EQUAL(filter, "(&(service.version>=1.2.3)(service.version<=1.2.3))");
versionRange_destroy(range);
+ free(filter);
}
TEST(version_range, createLdapFilterInclusiveLow) {
@@ -288,6 +285,7 @@ TEST(version_range, createLdapFilterInclusiveLow) {
STRCMP_EQUAL(filter, "(&(service.version>1.2.3)(service.version<=1.2.3))");
versionRange_destroy(range);
+ free(filter);
}
TEST(version_range, createLdapFilterInclusiveHigh) {
@@ -310,6 +308,7 @@ TEST(version_range, createLdapFilterInclusiveHigh) {
STRCMP_EQUAL(filter, "(&(service.version>=1.2.3)(service.version<1.2.3))");
versionRange_destroy(range);
+ free(filter);
}
TEST(version_range, createLdapFilterExclusiveBoth) {
@@ -332,6 +331,7 @@ TEST(version_range, createLdapFilterExclusiveBoth) {
STRCMP_EQUAL(filter, "(&(service.version>1.2.3)(service.version<1.2.3))");
versionRange_destroy(range);
+ free(filter);
}
TEST(version_range, createLdapFilterInfinite) {
@@ -348,6 +348,7 @@ TEST(version_range, createLdapFilterInfinite) {
STRCMP_EQUAL(filter, "(&(service.version>=1.2.3))");
versionRange_destroy(range);
+ free(filter);
}
TEST(version_range, createLdapFilterInPlaceInclusiveBoth) {