TLegend::AddEntry crashes if obj=0 && label=""

From: Christopher Backhouse <cjbackhouse_at_gmail.com>
Date: Fri, 21 Aug 2009 14:17:34 +0100


Hi,

I have a crash with TLegend, when calling AddEntry with obj=0 and label="" (I am abusing this function to produce internal spacing in the legend). TLegend seems to be happy with null objects in general, and merely passing label=" " works around this problem.

At line 229 in TLegend.cxx there is:

if ((obj && !label) || strlen(label)==0) lab = obj->GetTitle();

which is the line that crashes, it is attempting to protect against null 'obj' but it appears to be misbracketed. I would suggest:

if (obj && (!label || strlen(label)==0)) lab = obj->GetTitle();

This simple change ought to prevent dereferencing of null obj, and allow me to continue misusing TLegend :)

Thanks - Chris Received on Fri Aug 21 2009 - 15:17:38 CEST

This archive was generated by hypermail 2.2.0 : Mon Aug 24 2009 - 17:50:02 CEST