diff options
author | Drew DeVault <[email protected]> | 2016-12-17 13:23:44 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2016-12-17 13:23:44 -0500 |
commit | f04ee0e68d885d7e1101cc88f9a9337202041f1f (patch) | |
tree | fa4dc296a5f1377867752d320ceef4e4b0178bbf /sway/commands/bar/colors.c | |
parent | 6c0fc2093641868df28c4087902a040f7fae05d4 (diff) | |
parent | d859f825d3612492678f5cd6cc6dc1f2647929e1 (diff) |
Merge pull request #995 from SirCmpwn/memory-use
Handle allocation failures
Diffstat (limited to 'sway/commands/bar/colors.c')
-rw-r--r-- | sway/commands/bar/colors.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sway/commands/bar/colors.c b/sway/commands/bar/colors.c index f6fb520a..8b3b0aac 100644 --- a/sway/commands/bar/colors.c +++ b/sway/commands/bar/colors.c @@ -9,6 +9,9 @@ static struct cmd_results *parse_single_color(char **color, const char *cmd_name if (!*color) { *color = malloc(10); + if (!*color) { + return cmd_results_new(CMD_FAILURE, cmd_name, "Unable to allocate color"); + } } error = add_color(cmd_name, *color, argv[0]); @@ -29,6 +32,9 @@ static struct cmd_results *parse_three_colors(char ***colors, const char *cmd_na for (i = 0; i < 3; i++) { if (!*colors[i]) { *(colors[i]) = malloc(10); + if (!*(colors[i])) { + return cmd_results_new(CMD_FAILURE, cmd_name, "Unable to allocate color"); + } } error = add_color(cmd_name, *(colors[i]), argv[i]); if (error) { |