The g_free() function checks for NULL pointers

And so does even the free() function from glibc ;)
This commit is contained in:
Marcel Holtmann 2010-03-22 20:10:17 -07:00
parent e396b7d5af
commit 6cbfe5fa1e
1 changed files with 3 additions and 5 deletions

View File

@ -60,12 +60,10 @@ void auth_set_credentials(struct auth_data *data, const char *username,
if (data == NULL)
return;
if (data->username)
g_free(data->username);
if (data->passwd)
g_free(data->passwd);
g_free(data->username);
data->username = g_strdup(username);
g_free(data->passwd);
data->passwd = g_strdup(passwd);
}