diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-08-09 08:54:39 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-08-09 08:54:39 +0000 |
| commit | 828a57c2011eb797a9a257d124d48c641b3cac89 (patch) | |
| tree | cb2539f90c8a1be1ae330c807997dfc2a98e9481 /extract.c | |
| parent | changelog: add birger to 'contributers' for the upcoming release (diff) | |
| parent | Handle allocation failures explicitly in *_init() functions (diff) | |
Merge branch 'xmalloc-conversion' into master
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) |
