]> diplodocus.org Git - nmh/blobdiff - sbr/oauth.c
Newer versions of Automake want to include the test-driver script,
[nmh] / sbr / oauth.c
index 70de7dbe6dbf3cc1ba520c545f7eddb71f187e3d..b3e47a938972dd0a8ade20aa5a49bf767d49f7b4 100644 (file)
@@ -265,7 +265,7 @@ set_err_http(mh_oauth_ctx *ctx, const struct curl_ctx *curl_ctx)
     /* 5.2. Error Response says error response should use status code 400 and
      * application/json body.  If Content-Type matches, try to parse the body
      * regardless of the status code. */
-    if (curl_ctx->res_body != NULL
+    if (curl_ctx->res_len > 0
         && is_json(curl_ctx->content_type)
         && get_json_strings(curl_ctx->res_body, curl_ctx->res_len, ctx->log,
                             "error", &error, (void *)NULL)
@@ -786,7 +786,7 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx)
     user_creds->creds = mh_xmalloc(user_creds->alloc * sizeof *user_creds->creds);
 
     for (;;) {
-       size_t size = sizeof value_buf;
+       int size = sizeof value_buf;
        switch (state = m_getfld(&getfld_ctx, name, value_buf, &size, fp)) {
         case FLD:
         case FLDPLUS: {
@@ -954,6 +954,9 @@ mh_oauth_cred_load(FILE *fp, mh_oauth_ctx *ctx, const char *user)
         free(creds[i].user);
     }
 
+    /* No longer need user_creds.  result just uses its creds member. */
+    free(user_creds);
+
     if (result == NULL) {
         set_err_details(ctx, MH_OAUTH_CRED_USER_NOT_FOUND, user);
         return NULL;
@@ -1169,7 +1172,7 @@ parse_json(jsmntok_t **tokens, size_t *tokens_len,
            of the response body. */
         *tokens = mh_xrealloc(*tokens, *tokens_len * sizeof **tokens);
     }
-    if (r == 0) {
+    if (r <= 0) {
         return FALSE;
     }