forked from pool/libHX
54 lines
1.4 KiB
Plaintext
54 lines
1.4 KiB
Plaintext
Index: libHX-1.23/src/hmc.c
|
|
===================================================================
|
|
--- libHX-1.23.orig/src/hmc.c
|
|
+++ libHX-1.23/src/hmc.c
|
|
@@ -70,10 +70,14 @@ EXPORT_SYMBOL hmc_t *hmc_memasg(hmc_t **
|
|
CHECK_IDENT(ctx);
|
|
if (ctx->alloc < len) {
|
|
ctx = realloc(ctx, sizeof(struct memcont) + len);
|
|
+ if (ctx == NULL)
|
|
+ return NULL;
|
|
ctx->alloc = len;
|
|
}
|
|
} else {
|
|
ctx = malloc(sizeof(struct memcont) + len);
|
|
+ if (ctx == NULL)
|
|
+ return NULL;
|
|
ctx->id = HMC_IDENT;
|
|
ctx->alloc = len;
|
|
}
|
|
@@ -102,12 +106,14 @@ EXPORT_SYMBOL hmc_t *hmc_trunc(hmc_t **v
|
|
CHECK_IDENT(ctx);
|
|
if (len > ctx->alloc) {
|
|
ctx = realloc(ctx, sizeof(struct memcont) + len);
|
|
+ if (ctx == NULL)
|
|
+ return NULL;
|
|
ctx->alloc = len;
|
|
} else {
|
|
ctx->data[len] = '\0';
|
|
ctx->length = len;
|
|
}
|
|
- return ctx->data;
|
|
+ return *vp = ctx->data;
|
|
}
|
|
|
|
EXPORT_SYMBOL hmc_t *hmc_strcat(hmc_t **vp, const char *s)
|
|
@@ -125,6 +131,8 @@ EXPORT_SYMBOL hmc_t *hmc_memcat(hmc_t **
|
|
CHECK_IDENT(ctx);
|
|
if (nl > ctx->alloc) {
|
|
ctx = realloc(ctx, sizeof(struct memcont) + nl);
|
|
+ if (ctx == NULL)
|
|
+ return NULL;
|
|
ctx->alloc = nl;
|
|
}
|
|
if (ptr == NULL)
|
|
@@ -171,6 +179,8 @@ EXPORT_SYMBOL hmc_t *hmc_memins(hmc_t **
|
|
CHECK_IDENT(ctx);
|
|
if (ctx->alloc < nl) {
|
|
ctx = realloc(ctx, sizeof(struct memcont) + nl);
|
|
+ if (ctx == NULL)
|
|
+ return NULL;
|
|
ctx->alloc = nl;
|
|
}
|
|
if (ptr == NULL)
|