Fixed memory allocation bug in 'create_user_list' function

master
Aadhavan Srinivasan 2 years ago
parent 5bf131d00c
commit 3125dd48d6

@ -131,6 +131,10 @@ User** create_user_list(char* filename) {
char* token = malloc(sizeof(char) * 30);
User** users = malloc (num_users * sizeof(User*));
for (int i=0;i<num_users;i++) {
(*(users+i)) = malloc(sizeof(User));
}
token = strtok(file_str," \r\n");
for (int i=0;i<num_users;i++) {
(*(users + i))->username = strdup(token);

Loading…
Cancel
Save