Code

Merged branch 'master' of git://git.tokkee.org/sysdb.
authorSebastian Harl <sh@tokkee.org>
Tue, 10 Dec 2013 19:29:28 +0000 (20:29 +0100)
committerSebastian Harl <sh@tokkee.org>
Tue, 10 Dec 2013 19:29:28 +0000 (20:29 +0100)
1  2 
src/core/store.c

diff --combined src/core/store.c
@@@ -27,8 -27,8 +27,8 @@@
  
  #include "sysdb.h"
  #include "core/store.h"
 -#include "core/error.h"
  #include "core/plugin.h"
 +#include "utils/error.h"
  #include "utils/llist.h"
  
  #include <assert.h>
@@@ -418,11 -418,15 +418,15 @@@ sdb_store_attribute(const char *hostnam
                        /* 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 */
@@@ -533,7 -537,7 +537,7 @@@ sdb_store_tojson(sdb_strbuf_t *buf
                }
  
                sdb_llist_iter_destroy(svc_iter);
-               sdb_strbuf_append(buf, "]}");
+               sdb_strbuf_append(buf, "]},");
        }
  
        sdb_strbuf_append(buf, "]}");