Fix memory leak in instance->settings->password when reading from stdin

This commit is contained in:
Shea Levy 2011-09-08 02:10:22 -04:00
parent 6b8ac9ef18
commit 091e600127

View File

@ -729,9 +729,13 @@ int main(int argc, char* argv[])
return 1;
if (strcmp("-", instance->settings->password) == 0)
{
char* password;
password = xmalloc(512 * sizeof(char));
printf("Password: ");
fgets(instance->settings->password, 512-1, stdin);
*(instance->settings->password + strlen(instance->settings->password) - 1) = '\0';
fgets(password, 512 - 1, stdin);
*(password + strlen(password) - 1) = '\0';
xfree(instance->settings->password);
instance->settings->password = password;
}
data = (struct thread_data*) xzalloc(sizeof(struct thread_data));