Contour Plot / access contours

Here you go:

File cont.c

void cont()
{

  h_cont = new TH2D("h_cont","test", 10, 0, 10, 10, 0, 10);

  for (int i=0; i<10; i++){
    for (int j=0; j<10; j++){
      h_cont->SetBinContent(i,j,i*j);
    }
  }
  
  TCanvas *c1 = new TCanvas("c1","ctest");
  c1->Divide(1,2);
  

  c1->cd(1);
  h_cont->Draw("CONTLIST");
  
  c1->cd(2);
  
  TObjArray *contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
  TList *list = (TList*)contours->At(0);

  TGraph *gr1 = (TGraph*)list->First();

  gr1->Draw("ACP");
  
}

returns

Processing cont.c…
Error: illegal pointer to class object contours 0x0 34 FILE:cont.c LINE:23
*** Interpreter error recovered ***

If you remove TList… and all the following lines, then

  cout << contours->GetSize() << endl;

returns the proper value - 20.

Thanks!