summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-06-26 22:55:32 +0100
committerPhil Jones <philj56@gmail.com>2022-06-26 22:55:32 +0100
commit97aded721dd0bf33a56839517921e4c7094c90d7 (patch)
treea74ba8b52c368a9e8763dd1e952b4e561f61572a
parent5798c22da8ab204de46054871541e4363b6319e3 (diff)
Fix some minor memory error typos.
-rw-r--r--src/history.c3
-rw-r--r--src/main.c4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/history.c b/src/history.c
index 99edf79..7e2a84b 100644
--- a/src/history.c
+++ b/src/history.c
@@ -82,13 +82,14 @@ struct history history_load()
}
errno = 0;
- char *buf = xmalloc(len);
+ char *buf = xmalloc(len + 1);
if (fread(buf, 1, len, histfile) != len) {
log_error("Error reading history file: %s.\n", strerror(errno));
fclose(histfile);
return vec;
}
fclose(histfile);
+ buf[len] = '\0';
char *saveptr = NULL;
char *tok = strtok_r(buf, " ", &saveptr);
diff --git a/src/main.c b/src/main.c
index 920e6a6..d6f6d88 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1099,7 +1099,9 @@ int main(int argc, char *argv[])
wl_seat_release(tofi.wl_seat);
{
struct output_list_element *el;
- wl_list_for_each(el, &tofi.output_list, link) {
+ struct output_list_element *tmp;
+ wl_list_for_each_safe(el, tmp, &tofi.output_list, link) {
+ wl_list_remove(&el->link);
wl_output_release(el->wl_output);
free(el->name);
free(el);