From 0d998f17c495a12b04904113ff676c7427089883 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 31 Oct 2019 14:17:38 +0000 Subject: Fix gdevescv for operation with Memento. Blocks returned by system malloc can't be freed by Memento_free. Also, avoid a problem in CLUSTER builds. --- contrib/eplaser/gdevescv.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'contrib') diff --git a/contrib/eplaser/gdevescv.c b/contrib/eplaser/gdevescv.c index a13afef0b..7044eb7d2 100644 --- a/contrib/eplaser/gdevescv.c +++ b/contrib/eplaser/gdevescv.c @@ -33,9 +33,17 @@ */ +#include + +/* Get this definition in before we read memento.h */ +static void +unvectored_free(void *x) +{ + free(x); +} + #if ( 6 > GS_VERSION_MAJOR ) -#include #include /* for uname(2) */ #include /* for toupper(3) */ @@ -983,10 +991,12 @@ escv_beginpage(gx_device_vector * vdev) #ifdef CLUSTER memset(&tm, 0, sizeof(tm)); + strcpy(str, "1970/01/01 00:00:00"); + i = strlen(str); #else tm = localtime( &t ); -#endif i = strftime(str, 30, "%Y/%m/%d %H:%M:%S", tm); +#endif if ( 30 >= i ) str[i] = '\0'; @@ -1022,7 +1032,8 @@ escv_beginpage(gx_device_vector * vdev) if (sysname) { lputs(s, sysname ); - free (sysname); + /* Carefully avoid memento interfering here. */ + unvectored_free(sysname); sysname = NULL; } } -- cgit v1.2.1