From: Sebastian Harl Date: Sat, 7 Dec 2013 14:43:06 +0000 (+0100) Subject: store: Don't try to update non-existent attributes. X-Git-Tag: sysdb-0.1.0~314^2~6 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=0a929ff855616dd373508eef49570d6b52b52ef3 store: Don't try to update non-existent attributes. --- 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 */