From 11c74eaf001004b6166ba6a866ab0f69f67b8f78 Mon Sep 17 00:00:00 2001 From: fca Date: Fri, 26 Nov 1999 16:55:39 +0000 Subject: [PATCH 1/1] Reimplement CurrentVolName() to avoid memory leaks --- TGeant3/TGeant3.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/TGeant3/TGeant3.cxx b/TGeant3/TGeant3.cxx index 0a543d4c8f9..49a03a51dd8 100644 --- a/TGeant3/TGeant3.cxx +++ b/TGeant3/TGeant3.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.17 1999/11/03 16:58:28 fca +Correct source of address violation in creating character string + Revision 1.16 1999/11/03 13:17:08 fca Have ProdProcess return const char* @@ -650,12 +653,11 @@ const char* TGeant3::CurrentVolName() const // Returns the current volume name // Int_t i, gname; - char *name; + static char name[5]; if( (i=fGcvolu->nlevel-1) < 0 ) { Warning("CurrentVolName","Stack depth %d\n",fGcvolu->nlevel); } else { gname=fGcvolu->names[i]; - name = new char[5]; strncpy(name,(char *) &gname, 4); name[4]='\0'; i=fGcvolu->lvolum[i]; -- 2.39.3