diff options
author | Hisham <hisham@gobolinux.org> | 2016-02-02 15:53:02 +0100 |
---|---|---|
committer | Hisham <hisham@gobolinux.org> | 2016-02-02 15:53:02 +0100 |
commit | b54d2dde407921caa7561dde6b45831ba93d0840 (patch) | |
tree | cd81eea35dd65e46d22f2801ea403e1efc06eb59 /RichString.c | |
parent | a1f7f2869ec2bd860d5b4e4b39736ca877afdf6f (diff) |
Check for failure in allocations.
Diffstat (limited to 'RichString.c')
-rw-r--r-- | RichString.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/RichString.c b/RichString.c index 75198330..e7dd4e83 100644 --- a/RichString.c +++ b/RichString.c @@ -6,6 +6,7 @@ in the source distribution for its full text. */ #include "RichString.h" +#include "XAlloc.h" #include <stdlib.h> #include <string.h> @@ -67,7 +68,7 @@ typedef struct RichString_ { static void RichString_extendLen(RichString* this, int len) { if (this->chlen <= RICHSTRING_MAXLEN) { if (len > RICHSTRING_MAXLEN) { - this->chptr = malloc(charBytes(len + 1)); + this->chptr = xMalloc(charBytes(len + 1)); memcpy(this->chptr, this->chstr, charBytes(this->chlen)); } } else { @@ -76,7 +77,7 @@ static void RichString_extendLen(RichString* this, int len) { free(this->chptr); this->chptr = this->chstr; } else { - this->chptr = realloc(this->chptr, charBytes(len + 1)); + this->chptr = xRealloc(this->chptr, charBytes(len + 1)); } } |