forked from lda/telodendria
Fix use after free.
This commit is contained in:
parent
599fa1a740
commit
a4364dbb68
2 changed files with 11 additions and 2 deletions
|
@ -52,6 +52,7 @@ ROUTE_IMPL(RouteRegister, args)
|
||||||
char *deviceId = NULL;
|
char *deviceId = NULL;
|
||||||
|
|
||||||
Db *db = args->matrixArgs->db;
|
Db *db = args->matrixArgs->db;
|
||||||
|
LogConfig *lc = args->matrixArgs->lc;
|
||||||
|
|
||||||
User *user = NULL;
|
User *user = NULL;
|
||||||
|
|
||||||
|
@ -207,8 +208,10 @@ ROUTE_IMPL(RouteRegister, args)
|
||||||
{
|
{
|
||||||
/* TODO: Log in user here and attach auth info to response */
|
/* TODO: Log in user here and attach auth info to response */
|
||||||
}
|
}
|
||||||
UserUnlock(user);
|
|
||||||
|
|
||||||
|
Log(lc, LOG_INFO, "Registered user '%s'", UserGetName(user));
|
||||||
|
|
||||||
|
UserUnlock(user);
|
||||||
finish:
|
finish:
|
||||||
Free(username);
|
Free(username);
|
||||||
Free(password);
|
Free(password);
|
||||||
|
|
|
@ -121,13 +121,19 @@ UserLock(Db * db, char *name)
|
||||||
int
|
int
|
||||||
UserUnlock(User * user)
|
UserUnlock(User * user)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!user)
|
if (!user)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Free(user->name);
|
Free(user->name);
|
||||||
|
|
||||||
|
ret = DbUnlock(user->db, user->ref);
|
||||||
Free(user);
|
Free(user);
|
||||||
return DbUnlock(user->db, user->ref);
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
User *
|
User *
|
||||||
|
|
Loading…
Reference in a new issue