aboutsummarylogtreecommitdiffstats
path: root/portfolio.c
diff options
context:
space:
mode:
authorAntony Kellermann2018-05-13 16:35:41 -0400
committerAntony Kellermann2018-05-13 16:35:41 -0400
commit1d63a515a541a56a97beb8a7ab11e734f06d048a (patch)
tree79978d13672f2d98455abd72e564305f4940e30f /portfolio.c
parent6d8ce134613367a36c36a40e55043b817703fc6d (diff)
downloadaur-1d63a515a541a56a97beb8a7ab11e734f06d048a.tar.gz
Fixed SIGABRT sometimes caused by decryption
Diffstat (limited to 'portfolio.c')
-rw-r--r--portfolio.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/portfolio.c b/portfolio.c
index 6caf98e85666..3267b80c6cee 100644
--- a/portfolio.c
+++ b/portfolio.c
@@ -35,13 +35,14 @@ String* portfolio_file_get_string(char** password) {
fclose(fp);
Json* jobj = json_tokener_parse(pString->data);
- if (jobj == NULL) { // Portfolio must be encrypted if it cannot be parsed as JSON
+ if (jobj == NULL || !json_object_is_type(jobj, json_type_array)) { // Decrypt if not a JSON array
char* pw = rc4_getPassword();
puts("Decrypting portfolio...");
rc4_encode_string(pString, pw); // Decode using password
jobj = json_tokener_parse(pString->data);
- if (jobj == NULL) { // If cannot be parsed as JSON after decrypting, wrong password was entered
+ if (jobj == NULL || !json_object_is_type(jobj, json_type_array)) { // Wrong pw if not JSON array after decrypt
free(pw);
+ json_object_put(jobj);
string_destroy(&pString);
RETNULL_MSG("Wrong password!")
}