Removed double free

master
MadcowOG 2023-03-29 18:03:35 -07:00
parent 1aae27409b
commit dfbc79a558
1 changed files with 4 additions and 6 deletions

View File

@ -537,9 +537,8 @@ char* to_delimiter(char* string, ulong *start_end, char delimiter) {
return NULL; return NULL;
for ( i = *start_end; i < len; i++ ) { for ( i = *start_end; i < len; i++ ) {
if (string[i] == delimiter || i == len-1) { // We've reached the delimiter or the end. if (string[i] == delimiter) // We've reached the delimiter or the end.
break; break;
}
} }
/* Create and copy the substring what we need */ /* Create and copy the substring what we need */
@ -680,17 +679,16 @@ void on_status(void) {
char *line = get_line(fifo_fd), *command, *status; char *line = get_line(fifo_fd), *command, *status;
ulong loc = 0; ulong loc = 0;
if (!line || !strlen(line)) { if (!line || !strlen(line)) {
free(line); if (line)
free(line);
return; return;
} }
command = to_delimiter(line, &loc, ' '); command = to_delimiter(line, &loc, ' ');
status = to_delimiter(line, &loc, '\n'); status = to_delimiter(line, &loc, '\n');
if (strcmp(command, "status") != EQUAL) { if (strcmp(command, "status") != EQUAL)
free(status);
goto done; goto done;
}
Monitor *current_monitor; Monitor *current_monitor;
wl_list_for_each(current_monitor, &monitors, link) { wl_list_for_each(current_monitor, &monitors, link) {