summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorLiam Hopkins <liamh@google.com>2019-07-31 11:25:06 -0700
committerMax Illfelder <illfelder@users.noreply.github.com>2019-07-31 11:25:06 -0700
commit681c8d7b770e0f450ecf961d358d02e357fd7423 (patch)
treefb4c91127ab4a94a4a2797aca584470d58db576f /packages
parent466dc6e8e7900693d73526084b888df82e6eab85 (diff)
downloadgoogle-compute-image-packages-681c8d7b770e0f450ecf961d358d02e357fd7423.tar.gz
Correct JSON refcount decrementing (#821)
Diffstat (limited to 'packages')
-rw-r--r--packages/google-compute-engine-oslogin/src/utils.cc9
1 files changed, 2 insertions, 7 deletions
diff --git a/packages/google-compute-engine-oslogin/src/utils.cc b/packages/google-compute-engine-oslogin/src/utils.cc
index c97529e..0f05f6f 100644
--- a/packages/google-compute-engine-oslogin/src/utils.cc
+++ b/packages/google-compute-engine-oslogin/src/utils.cc
@@ -800,7 +800,7 @@ bool StartSession(const string& email, string* response) {
jobj = json_object_new_object();
json_object_object_add(jobj, "email", json_object_new_string(email.c_str()));
- json_object_object_add(jobj, "supportedChallengeTypes", jarr);
+ json_object_object_add(jobj, "supportedChallengeTypes", jarr); // Ownership transferred to jobj.
const char* data;
data = json_object_to_json_string_ext(jobj, JSON_C_TO_STRING_PLAIN);
@@ -814,7 +814,6 @@ bool StartSession(const string& email, string* response) {
ret = false;
}
- json_object_put(jarr);
json_object_put(jobj);
return ret;
@@ -843,7 +842,7 @@ bool ContinueSession(bool alt, const string& email, const string& user_token,
jresp = json_object_new_object();
json_object_object_add(jresp, "credential",
json_object_new_string(user_token.c_str()));
- json_object_object_add(jobj, "proposalResponse", jresp);
+ json_object_object_add(jobj, "proposalResponse", jresp); // Ownership transferred to jobj.
}
const char* data = NULL;
@@ -859,10 +858,6 @@ bool ContinueSession(bool alt, const string& email, const string& user_token,
}
json_object_put(jobj);
- // Match condition where we created this to avoid double-free.
- if (challenge.type != AUTHZEN && !alt) {
- json_object_put(jresp);
- }
return ret;
}