Histogram division gives segmentation trace error

I’ve a pretty simple code, not sure why it gives me a segmentation error.

[code][color=#BF0000]#include <TH1D.h>

void temp(){

    TH1D *h1 = new TH1D("h1", "", 1000, -10, 10);
    TH1D *h2 = new TH1D("h2", "", 1000, -10, 10);
    h1->FillRandom("gaus", 100000);
    h2->FillRandom("landau", 100000);

    h1->Draw();

    TH1D *h3 = 0;
    h3 = (TH1D*)h2->Divide(h1);
    h3->Draw("same");

}[/color]
[/code]

Help appreciated

Bool_t TH1::Divide(const TH1* h1)

maybe you can use this to replace your code “h3 = (TH1D*)h2->Divide(h1);”

                 h3=(TH1D*)h2->Clone();
                 h3->Divide(h1);
                 h3->SetLineColor(2);

because when divide h2->Divide(h1),the plot will store at h2,then you can draw it.
set color is just to make the 2 lines easy to identify.

TH1D h3 = (TH1D)h2->Clone(“h3”);