From 0a929ff855616dd373508eef49570d6b52b52ef3 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 7 Dec 2013 15:43:06 +0100 Subject: [PATCH] store: Don't try to update non-existent attributes. --- src/core/store.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/store.c b/src/core/store.c index 587c527..95aaafa 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -418,11 +418,15 @@ sdb_store_attribute(const char *hostname, const char *key, const char *value, /* stored object = */ SDB_ATTRIBUTE, key, last_update, &updated_attr); - SDB_ATTR(updated_attr)->value = strdup(value); - if (! SDB_ATTR(updated_attr)->value) { - sdb_object_deref(SDB_OBJ(updated_attr)); - status = -1; + if (status >= 0) { + assert(updated_attr); + SDB_ATTR(updated_attr)->value = strdup(value); + if (! SDB_ATTR(updated_attr)->value) { + sdb_object_deref(SDB_OBJ(updated_attr)); + status = -1; + } } + pthread_rwlock_unlock(&obj_lock); return status; } /* sdb_store_attribute */ -- 2.30.2