Commit 126a8ca3e96dea686f42fbf822d8cf519668e232
1 parent
5e596ad3
fixed various memory management issues detected with valgrind
Showing
9 changed files
with
24 additions
and
16 deletions
... | ... | @@ -42,14 +42,13 @@ controllerSignupCreate( |
42 | 42 | { |
43 | 43 | Credential credential; |
44 | 44 | User user; |
45 | + Uuid user_id; | |
45 | 46 | char * response_data; |
46 | 47 | |
47 | 48 | _controllerProcessUserCreateArgs(args, &user, &credential); |
48 | 49 | |
49 | - if (0 == uuidCompare( | |
50 | - uuidZero, | |
51 | - applicationCreateUser(application, credential, user))) | |
52 | - { | |
50 | + user_id = applicationCreateUser(application, credential, user); | |
51 | + if (0 == uuidCompare(uuidZero, user_id)) { | |
53 | 52 | response_data = NULL; |
54 | 53 | } else { |
55 | 54 | applicationLogin(application, credential, session); |
... | ... | @@ -58,6 +57,7 @@ controllerSignupCreate( |
58 | 57 | |
59 | 58 | delete(credential); |
60 | 59 | delete(user); |
60 | + delete(user_id); | |
61 | 61 | |
62 | 62 | return response_data; |
63 | 63 | ... | ... |
... | ... | @@ -41,14 +41,13 @@ controllerUserCreate( |
41 | 41 | { |
42 | 42 | Credential credential; |
43 | 43 | User user; |
44 | + Uuid user_id; | |
44 | 45 | char * response_data; |
45 | 46 | |
46 | 47 | _controllerProcessUserCreateArgs(args, &user, &credential); |
47 | 48 | |
48 | - if (0 == uuidCompare( | |
49 | - uuidZero, | |
50 | - applicationCreateUser(application, credential, user))) | |
51 | - { | |
49 | + user_id = applicationCreateUser(application, credential, user); | |
50 | + if (0 == uuidCompare(uuidZero, user_id)) { | |
52 | 51 | response_data = NULL; |
53 | 52 | } else { |
54 | 53 | response_data = controllerCurrentuserRead(application, session, NULL); |
... | ... | @@ -56,6 +55,7 @@ controllerUserCreate( |
56 | 55 | |
57 | 56 | delete(credential); |
58 | 57 | delete(user); |
58 | + delete(user_id); | |
59 | 59 | |
60 | 60 | return response_data; |
61 | 61 | } | ... | ... |
... | ... | @@ -39,16 +39,17 @@ controllerUserUpdate( |
39 | 39 | Session session, |
40 | 40 | Hash args) |
41 | 41 | { |
42 | + Uuid user_id; | |
43 | + | |
42 | 44 | if (! _controllerUpdateUserFromArgs(args, &(session->user))) { |
43 | 45 | return NULL; |
44 | 46 | } |
45 | 47 | |
46 | - if (0 == uuidCompare( | |
47 | - uuidZero, | |
48 | - applicationUpdateUser(application, session->user))) | |
49 | - { | |
48 | + user_id = applicationUpdateUser(application, session->user); | |
49 | + if (0 == uuidCompare(uuidZero, user_id)) { | |
50 | 50 | return NULL; |
51 | 51 | } |
52 | + delete(user_id); | |
52 | 53 | |
53 | 54 | return controllerCurrentuserRead(application, session, NULL); |
54 | 55 | } | ... | ... |
... | ... | @@ -48,8 +48,6 @@ applicationUpdatePassword( |
48 | 48 | unsigned char * hash = hash_data+SALT_SIZE; |
49 | 49 | Uuid index; |
50 | 50 | |
51 | - index = indexUuid(user, this->user_namespace); | |
52 | - | |
53 | 51 | if (FALSE == hash_pw( |
54 | 52 | CRED_PWD(cred).pass, |
55 | 53 | CRED_PWD(cred).npass, |
... | ... | @@ -61,12 +59,14 @@ applicationUpdatePassword( |
61 | 59 | memcpy(hash_data, salt, SALT_SIZE); |
62 | 60 | MEM_FREE(salt); |
63 | 61 | |
62 | + index = indexUuid(user, this->user_namespace); | |
64 | 63 | storageUpdate( |
65 | 64 | this->passwords, |
66 | 65 | (char *)(index->uuid).value, |
67 | 66 | sizeof((index->uuid).value), |
68 | 67 | (char *)hash_data, |
69 | 68 | SALT_SIZE + HASH_SIZE); |
69 | + delete(index); | |
70 | 70 | |
71 | 71 | return TRUE; |
72 | 72 | } | ... | ... |
... | ... | @@ -54,7 +54,7 @@ configValueCtor(void * _this, va_list * params) |
54 | 54 | { |
55 | 55 | this->type = CONFIG_VALUE_STRING; |
56 | 56 | (this->value).string = memMalloc(nvalue-1); |
57 | - (this->value).string[nvalue-1] = '\0'; | |
57 | + (this->value).string[nvalue-2] = '\0'; | |
58 | 58 | memcpy((this->value).string, value+1, nvalue-2); |
59 | 59 | this->nvalue = nvalue; |
60 | 60 | } else { | ... | ... |
Please
register
or
login
to post a comment