You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by bp...@apache.org on 2015/11/18 09:42:46 UTC
celix git commit: CELIX-289: add some additonal error checking
Repository: celix
Updated Branches:
refs/heads/develop 4d58af88b -> 378e1891e
CELIX-289: add some additonal error checking
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/378e1891
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/378e1891
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/378e1891
Branch: refs/heads/develop
Commit: 378e1891e45e664953c9d1cb172e319ef93c9793
Parents: 4d58af8
Author: Bjoern Petri <bp...@apache.org>
Authored: Wed Nov 18 09:41:38 2015 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Wed Nov 18 09:41:38 2015 +0100
----------------------------------------------------------------------
remote_services/discovery_etcd/private/src/etcd.c | 11 ++++++++---
.../discovery_etcd/private/src/etcd_watcher.c | 3 ++-
2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/378e1891/remote_services/discovery_etcd/private/src/etcd.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/src/etcd.c b/remote_services/discovery_etcd/private/src/etcd.c
index 24bc6bc..e298ae4 100644
--- a/remote_services/discovery_etcd/private/src/etcd.c
+++ b/remote_services/discovery_etcd/private/src/etcd.c
@@ -136,9 +136,14 @@ bool etcd_get(char* key, char* value, char* action, int* modifiedIndex) {
js_value = json_object_get(js_node, ETCD_JSON_VALUE);
js_modifiedIndex = json_object_get(js_node, ETCD_JSON_MODIFIEDINDEX);
- *modifiedIndex = json_integer_value(js_modifiedIndex);
- snprintf(value, MAX_VALUE_LENGTH, "%s", json_string_value(js_value));
- retVal = true;
+ if (js_modifiedIndex != NULL) {
+ *modifiedIndex = json_integer_value(js_modifiedIndex);
+ }
+
+ if (js_value != NULL) {
+ snprintf(value, MAX_VALUE_LENGTH, "%s", json_string_value(js_value));
+ retVal = true;
+ }
}
if (js_root != NULL) {
json_decref(js_root);
http://git-wip-us.apache.org/repos/asf/celix/blob/378e1891/remote_services/discovery_etcd/private/src/etcd_watcher.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_etcd/private/src/etcd_watcher.c b/remote_services/discovery_etcd/private/src/etcd_watcher.c
index a715a66..9e3a0f7 100644
--- a/remote_services/discovery_etcd/private/src/etcd_watcher.c
+++ b/remote_services/discovery_etcd/private/src/etcd_watcher.c
@@ -231,7 +231,6 @@ static celix_status_t etcdWatcher_removeEntry(etcd_watcher_pt watcher, char* key
void* value = hashMap_remove(watcher->entries, key);
free(origKey);
- free(value);
// check if there is another entry with the same value
hash_map_iterator_pt iter = hashMapIterator_create(watcher->entries);
@@ -247,6 +246,8 @@ static celix_status_t etcdWatcher_removeEntry(etcd_watcher_pt watcher, char* key
if (valueFound == 0)
status = endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, value);
+ free(value);
+
}
return status;