(no commit message)
[prss.git] / src / ttrss.c
index ae4a1c9..97f2803 100644 (file)
@@ -94,8 +94,11 @@ struct json_object *ws_execute(struct json_object *rq)
        if (rp) {
                content = ws_reply_get_content(rp);
 
-               if (content && !json_object_object_get(rp, "error"))
+               if (content && !json_object_object_get(rp, "error")) {
+                       json_object_get(content);
+                       json_object_put(rp);
                        return content;
+               }
 
                json_object_put(rp);
        }
@@ -105,7 +108,7 @@ struct json_object *ws_execute(struct json_object *rq)
 
 int ws_get_api_version()
 {
-       struct json_object *rp, *rq, *j;
+       struct json_object *rp, *rq;
        int v;
 
        rq = ws_request_new("getApiLevel");
@@ -115,12 +118,7 @@ int ws_get_api_version()
        json_object_put(rq);
 
        if (rp) {
-               j = json_object_object_get(rp, "level");
-
-               if (j)
-                       v = json_object_get_int(j);
-               else
-                       v = 0;
+               v = json_object_get_int(json_object_object_get(rp, "level"));
 
                json_object_put(rp);
        } else {
@@ -144,11 +142,7 @@ char *ws_login()
 
        if (rp) {
                j = json_object_object_get(rp, "session_id");
-
-               if (j)
-                       str = strdup(json_object_get_string(j));
-               else
-                       str = NULL;
+               str = strdup(json_object_get_string(j));
 
                json_object_put(rp);
        } else {