wmbattery: fix a couple of potential memory-leaks.
In `cmd_crit`, if there is an allocation failure, we return from the function immediately and leak any previously allocated memory. Go to the clean-up code at the end of the function instead. Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
This commit is contained in:
parent
be9c86487d
commit
25dacf9256
|
@ -359,18 +359,20 @@ void cmd_crit(const char *cmd, int percentage, int time)
|
|||
return;
|
||||
tmp_b = replace_str(tmp_a, STR_SUB_MINUTES, min_str);
|
||||
if (!tmp_b)
|
||||
return;
|
||||
goto free_tmp_a;
|
||||
command = replace_str(tmp_b, STR_SUB_SECONDS, sec_str);
|
||||
if (!command)
|
||||
return;
|
||||
goto free_tmp_b;
|
||||
|
||||
ret = system(command);
|
||||
if (ret == -1)
|
||||
error("unable to run command: %s", command);
|
||||
|
||||
free(tmp_a);
|
||||
free(tmp_b);
|
||||
free(command);
|
||||
free_tmp_b:
|
||||
free(tmp_b);
|
||||
free_tmp_a:
|
||||
free(tmp_a);
|
||||
}
|
||||
|
||||
/* Returns the display to run on (or NULL for default). */
|
||||
|
|
Loading…
Reference in a new issue