aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2024-01-25 07:03:50 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2024-01-25 07:03:50 +0000
commit91b22ae21acd0b3171814b47b0dead027f8da779 (patch)
tree6504247289226858803cded93ffff0dd8aafcad0
parentwayland: 'mode' is unused when LOG_ENABLE_DBG is not set (diff)
Replace unchecked allocations with calls to xmalloc.h functions
-rw-r--r--char32.c4
-rw-r--r--config.c2
-rw-r--r--render.c2
-rw-r--r--server.c2
-rw-r--r--shm.c2
-rw-r--r--spawn.c2
6 files changed, 7 insertions, 7 deletions
diff --git a/char32.c b/char32.c
index e25db3f1..97c599d9 100644
--- a/char32.c
+++ b/char32.c
@@ -129,11 +129,11 @@ UNITTEST
UNITTEST
{
- char32_t *c = c32dup(U"foobar");
+ char32_t *c = xc32dup(U"foobar");
xassert(c32cmp(c, U"foobar") == 0);
free(c);
- c = c32dup(U"");
+ c = xc32dup(U"");
xassert(c32cmp(c, U"") == 0);
free(c);
}
diff --git a/config.c b/config.c
index de15add3..f964f7c1 100644
--- a/config.c
+++ b/config.c
@@ -3213,7 +3213,7 @@ config_load(struct config *conf, const char *conf_path,
ret = false;
} else {
conf->fonts[0].count = 1;
- conf->fonts[0].arr = malloc(sizeof(font));
+ conf->fonts[0].arr = xmalloc(sizeof(font));
conf->fonts[0].arr[0] = font;
}
}
diff --git a/render.c b/render.c
index d679b5e8..a522c24c 100644
--- a/render.c
+++ b/render.c
@@ -1460,7 +1460,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat,
* from grid), and mark all cells as dirty. This ensures they are
* re-rendered when the pre-edit text is modified or removed.
*/
- struct cell *real_cells = malloc(cells_used * sizeof(real_cells[0]));
+ struct cell *real_cells = xmalloc(cells_used * sizeof(real_cells[0]));
for (int i = 0; i < cells_used; i++) {
xassert(col_idx + i < term->cols);
real_cells[i] = row->cells[col_idx + i];
diff --git a/server.c b/server.c
index 7cc87152..068ca057 100644
--- a/server.c
+++ b/server.c
@@ -301,7 +301,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
#undef CHECK_BUF_AND_NULL
#undef CHECK_BUF
- struct terminal_instance *instance = malloc(sizeof(struct terminal_instance));
+ struct terminal_instance *instance = xmalloc(sizeof(struct terminal_instance));
const bool need_to_clone_conf =
tll_length(overrides)> 0 ||
diff --git a/shm.c b/shm.c
index 171459f6..87bd33a7 100644
--- a/shm.c
+++ b/shm.c
@@ -489,7 +489,7 @@ get_new_buffers(struct buffer_chain *chain, size_t count,
else
tll_push_front(chain->bufs, buf);
- buf->public.dirty = malloc(
+ buf->public.dirty = xmalloc(
chain->pix_instances * sizeof(buf->public.dirty[0]));
for (size_t j = 0; j < chain->pix_instances; j++)
diff --git a/spawn.c b/spawn.c
index 90b892f3..6935a29a 100644
--- a/spawn.c
+++ b/spawn.c
@@ -145,7 +145,7 @@ spawn_expand_template(const struct config_spawn_template *template,
expanded[len] = '\0'; \
} while (0)
- *argv = malloc((*argc + 1) * sizeof((*argv)[0]));
+ *argv = xmalloc((*argc + 1) * sizeof((*argv)[0]));
/* Expand the provided keys */
for (size_t i = 0; i < *argc; i++) {