aboutsummaryrefslogtreecommitdiffstats
path: root/xmlmemory.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2005-05-08 11:39:56 +0000
committerDaniel Veillard <veillard@src.gnome.org>2005-05-08 11:39:56 +0000
commit942d6c7b4f6f0fbc5855a00891961a940963aa93 (patch)
tree8fa9a166d4b99f3c8e14cf219dacb2d71bf2929a /xmlmemory.c
parent99dd7636a44208a14bc71614120f8ef4b8123016 (diff)
downloadandroid_external_libxml2-942d6c7b4f6f0fbc5855a00891961a940963aa93.tar.gz
android_external_libxml2-942d6c7b4f6f0fbc5855a00891961a940963aa93.tar.bz2
android_external_libxml2-942d6c7b4f6f0fbc5855a00891961a940963aa93.zip
fixed #169630 segfault in xmlMemDisplay Daniel
* xmlmemory.c: fixed #169630 segfault in xmlMemDisplay Daniel
Diffstat (limited to 'xmlmemory.c')
-rw-r--r--xmlmemory.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/xmlmemory.c b/xmlmemory.c
index 1bbc315a..18e0ff14 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -642,7 +642,18 @@ xmlMemDisplay(FILE *fp)
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(&currentTime);
strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct);
@@ -668,6 +679,8 @@ xmlMemDisplay(FILE *fp)
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 @@ xmlMemDisplay(FILE *fp)
#else
fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n");
#endif
+ if (old_fp == NULL)
+ fclose(fp);
}
#ifdef MEM_LIST