fixed #169630 segfault in xmlMemDisplay Daniel
* xmlmemory.c: fixed #169630 segfault in xmlMemDisplay
Daniel
diff --git a/ChangeLog b/ChangeLog
index 7c1dca9..7f6001f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun May 8 13:35:39 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+ * xmlmemory.c: fixed #169630 segfault in xmlMemDisplay
+
Fri May 6 13:40:03 CEST 2005 Daniel Veillard <daniel@veillard.com>
* nanoftp.c: fixing bug #303068 increasing the nanoftp buffer.
diff --git a/xmlmemory.c b/xmlmemory.c
index 1bbc315..18e0ff1 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -642,7 +642,18 @@
time_t currentTime;
char buf[500];
struct tm * tstruct;
+#endif
+#endif
+ FILE *old_fp = fp;
+ if (fp == NULL) {
+ fp = fopen(".memorylist", "w");
+ if (fp == NULL)
+ return;
+ }
+
+#ifdef MEM_LIST
+#if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME)
currentTime = time(NULL);
tstruct = localtime(¤tTime);
strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct);
@@ -668,6 +679,8 @@
default:
fprintf(fp,"Unknown memory block, may be corrupted");
xmlMutexUnlock(xmlMemMutex);
+ if (old_fp == NULL)
+ fclose(fp);
return;
}
if (p->mh_file != NULL) fprintf(fp,"%s(%u)", p->mh_file, p->mh_line);
@@ -686,6 +699,8 @@
#else
fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n");
#endif
+ if (old_fp == NULL)
+ fclose(fp);
}
#ifdef MEM_LIST