Skip to content

Commit

Permalink
[GH#70] Fix Crash When password-alignment Is Missing
Browse files Browse the repository at this point in the history
Fix a crash caused by trying to free() a static string constant returned
by `parse_greeter_string`. To prevent this, we now create a duplicate of
the fallback value when the configuration option is missing.

Fixes GH#70
  • Loading branch information
prikhi committed Mar 2, 2021
1 parent e8ce8ad commit 791721e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master

* Fix crash when `password-alignment` option is missing from configration file.

## v0.5.0

Expand Down
6 changes: 3 additions & 3 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ void destroy_config(Config *config)
}


/* Parse a string from the config file, returning the fallback value if the key
* is not present in the group.
/* Parse a string from the config file, returning a copy of the fallback value
* if the key is not present in the group.
*/
static gchar *parse_greeter_string(GKeyFile *keyfile, const char *group_name,
const char *key_name, const gchar *fallback)
{
gchar *parsed_string = g_key_file_get_string(keyfile, group_name, key_name, NULL);
if (parsed_string == NULL) {
return (gchar *) fallback;
return g_strdup(fallback);
} else {
return parsed_string;
}
Expand Down

0 comments on commit 791721e

Please # to comment.