diff --git a/libHX-hmc-fixes.dif b/libHX-hmc-fixes.dif new file mode 100644 index 0000000..04bd309 --- /dev/null +++ b/libHX-hmc-fixes.dif @@ -0,0 +1,53 @@ +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) diff --git a/libHX.changes b/libHX.changes index 1cfab50..48ebdcf 100644 --- a/libHX.changes +++ b/libHX.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Sep 25 14:54:25 CEST 2008 - mc@suse.de + +- pointer was not automatically updated after hmc_trunc() +- make code resistant to memory allocation failure + ------------------------------------------------------------------- Fri Sep 5 09:56:48 CEST 2008 - mc@suse.de diff --git a/libHX.spec b/libHX.spec index 7f1fa1c..90cc91c 100644 --- a/libHX.spec +++ b/libHX.spec @@ -23,11 +23,12 @@ Name: libHX BuildRequires: gcc-c++ libxml2-devel Summary: General-purpose Library Version: 1.23 -Release: 1 +Release: 2 License: LGPL v2.1 or later; LGPL v3 or later Prefix: /usr Group: System/Libraries Source: %{name}-%{version}.tar.bz2 +Patch1: libHX-hmc-fixes.dif BuildRoot: %{_tmppath}/%{name}-%{version}-build %define debug_package_requires libHX13 = %{version} Url: http://jengelh.medozas.de/projects/libHX/ @@ -128,6 +129,7 @@ Authors: %prep %setup -q -n %{name}-%{version} +%patch1 -p1 %build ./autogen.sh; @@ -162,6 +164,9 @@ rm -rf $RPM_BUILD_ROOT %_libdir/pkgconfig/*.pc %changelog +* Thu Sep 25 2008 mc@suse.de +- pointer was not automatically updated after hmc_trunc() +- make code resistant to memory allocation failure * Fri Sep 05 2008 mc@suse.de - update to version 1.23 - code cleanup: misc.h has been split off libHX.h