From 44d82d89501ed38a063b1fdb97f53d953e56e8a0 Mon Sep 17 00:00:00 2001
From: Rene Brun <Rene.Brun@cern.ch>
Date: Tue, 8 Jul 2003 06:57:07 +0000
Subject: [PATCH] Protect TH1::Fit in case of a Zombie function

git-svn-id: http://root.cern.ch/svn/root/trunk@6853 27541ba8-7e3a-0410-8455-c3a389f83636
---
 hist/src/TH1.cxx | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hist/src/TH1.cxx b/hist/src/TH1.cxx
index 5bc4fa34706..9a5665937fb 100644
--- a/hist/src/TH1.cxx
+++ b/hist/src/TH1.cxx
@@ -1,4 +1,4 @@
-// @(#)root/hist:$Name:  $:$Id: TH1.cxx,v 1.149 2003/06/30 09:03:56 brun Exp $
+// @(#)root/hist:$Name:  $:$Id: TH1.cxx,v 1.150 2003/07/02 21:18:21 brun Exp $
 // Author: Rene Brun   26/12/94
 
 /*************************************************************************
@@ -1940,14 +1940,14 @@ Int_t TH1::Fit(TF1 *f1 ,Option_t *option ,Option_t *goption, Axis_t xxmin, Axis_
    gF1 = f1;
    hFitter->SetUserFunc(f1);
    if (!f1) { Error("Fit", "Pointer to function is null"); return 0; }
+   if (f1->IsZombie()) { Error("Fit", "Function is zombie"); return 0; }
    npar = f1->GetNpar();
    if (npar <=0) { Error("Fit", "Illegal number of parameters = %d",npar); return 0; }
-
 //   - Check that function has same dimension as histogram
-   if (f1->GetNdim() == 1 && GetDimension() > 1) {
-      Error("Fit", "Function %s is not 2-D",f1->GetName()); return 0; }
-   if (f1->GetNdim() == 2 && GetDimension() < 2) {
-      Error("Fit", "Function %s is not 1-D",f1->GetName()); return 0; }
+   if (f1->GetNdim() != GetDimension()) {
+      Error("Fit","Function dimension:%d does not match histogram dimension:%d",f1->GetNdim(),GetDimension());
+      return 0;
+   }
    if (xxmin != xxmax) f1->SetRange(xxmin,ymin,zmin,xxmax,ymax,zmax);
 
 //   - Decode list of options into Foption
-- 
GitLab