summaryrefslogtreecommitdiff
path: root/xs.h
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-10-07 09:46:23 +0200
committerdefault <nobody@localhost>2022-10-07 09:46:23 +0200
commita62e830ced0e3ee425e6f8be26624bdd5f504b73 (patch)
tree056483a0aa38de382d6385be8935cebd68dbd739 /xs.h
parentd2edc2aa9bbdc52be6ff66e202634e3b28c8c35e (diff)
abort() on realloc() error.
Diffstat (limited to 'xs.h')
-rw-r--r--xs.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/xs.h b/xs.h
index c44a8a0..079b1f2 100644
--- a/xs.h
+++ b/xs.h
@@ -213,8 +213,18 @@ d_char *xs_expand(d_char *data, int offset, int size)
int n;
/* open room */
- if (sz == 0 || _xs_blk_size(sz) != _xs_blk_size(sz + size))
- data = realloc(data, _xs_blk_size(sz + size));
+ if (sz == 0 || _xs_blk_size(sz) != _xs_blk_size(sz + size)) {
+ d_char *ndata;
+
+ ndata = realloc(data, _xs_blk_size(sz + size));
+
+ if (ndata == NULL) {
+ fprintf(stderr, "**OUT OF MEMORY**");
+ abort();
+ }
+ else
+ data = ndata;
+ }
/* move up the rest of the data */
for (n = sz + size - 1; n >= offset + size; n--)