diff options
| author | Craig Barnes <craigbarnes@protonmail.com> | 2020-08-08 19:34:30 +0000 |
|---|---|---|
| committer | Craig Barnes <craigbarnes@protonmail.com> | 2020-08-08 19:37:57 +0000 |
| commit | 7a77958ba20c2b344be5e66e69e2f212a4bbf6b3 (patch) | |
| tree | cdb8191177f5f9ca69ea7858f9543f36fcbcf616 /extract.c | |
| parent | changelog: add birger to 'contributers' for the upcoming release (diff) | |
Convert most dynamic allocations to use functions from xmalloc.h
Diffstat (limited to 'extract.c')
| -rw-r--r-- | extract.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -20,6 +20,11 @@ struct extraction_context * extract_begin(enum selection_kind kind) { struct extraction_context *ctx = malloc(sizeof(*ctx)); + if (unlikely(ctx == NULL)) { + LOG_ERRNO("malloc() failed"); + return NULL; + } + *ctx = (struct extraction_context){ .selection_kind = kind, }; @@ -80,6 +85,11 @@ extract_finish(struct extraction_context *ctx, char **text, size_t *len) } *text = malloc(_len + 1); + if (unlikely(text == NULL)) { + LOG_ERRNO("malloc() failed"); + goto out; + } + wcstombs(*text, ctx->buf, _len + 1); if (len != NULL) |
