Changeset: 807e5055e780 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=807e5055e780 Modified Files: monetdb5/mal/mal_authorize.c Branch: Jan2014 Log Message:
Close resource leak: first check and maybe return, then allocate. diffs (49 lines): diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c --- a/monetdb5/mal/mal_authorize.c +++ b/monetdb5/mal/mal_authorize.c @@ -640,8 +640,7 @@ AUTHdecypherValue(str *ret, str *value) */ /* this is the XOR decypher implementation */ - str r = GDKmalloc(sizeof(char) * (strlen(*value) + 1)); - str w = r; + str r, w; str s = *value; char t = '\0'; int escaped = 0; @@ -649,10 +648,11 @@ AUTHdecypherValue(str *ret, str *value) * (a space would only uppercase the password) */ int keylen = 0; + if (vaultKey == NULL) + throw(MAL, "decypherValue", "The vault is still locked!"); + r = GDKmalloc(sizeof(char) * (strlen(*value) + 1)); if( r == NULL) throw(MAL, "decypherValue", MAL_MALLOC_FAIL); - if (vaultKey == NULL) - throw(MAL, "decypherValue", "The vault is still locked!"); keylen = (int) strlen(vaultKey); @@ -683,17 +683,17 @@ AUTHdecypherValue(str *ret, str *value) static str AUTHcypherValue(str *ret, str *value) { /* this is the XOR cypher implementation */ - str r = GDKmalloc(sizeof(char) * (strlen(*value) * 2 + 1)); - str w = r; + str r, w; str s = *value; /* we default to some garbage key, just to make password unreadable * (a space would only uppercase the password) */ int keylen = 0; + if (vaultKey == NULL) + throw(MAL, "cypherValue", "The vault is still locked!"); + w = r = GDKmalloc(sizeof(char) * (strlen(*value) * 2 + 1)); if( r == NULL) throw(MAL, "cypherValue", MAL_MALLOC_FAIL); - if (vaultKey == NULL) - throw(MAL, "cypherValue", "The vault is still locked!"); keylen = (int) strlen(vaultKey); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list