View Issue Details

IDProjectCategoryView StatusLast Update
0005861JEDI VCL00 JVCL Componentspublic2015-09-21 17:47
ReporterRHoekAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.49 
Summary0005861: TJvInspectorClassItem.GetDisplayValue return value might be invalid (JvInspector)
DescriptionThe code uses a non-initialized return value in GetDisplayValue (depending the situation).... (See ***)

function TJvInspectorClassItem.GetDisplayValue: string;
var
  Obj: TObject;
  SL: TStringList;
  I: Integer;
begin
  Obj := TObject(Data.AsOrdinal);
  if ShowClassName then
  begin
    if Obj <> nil then
      Result := Result*** + '(' + Obj.ClassName + ')'
    else
      Result := Result*** + '(' + GetTypeData(Data.TypeInfo).ClassType.ClassName + ')';
  end
  else.......

*** return value has not yet been initialized
Additional Informationfunction TJvInspectorClassItem.GetDisplayValue: string;
var
  Obj: TObject;
  SL: TStringList;
  I: Integer;
begin
  Obj := TObject(Data.AsOrdinal);
  if ShowClassName then
  begin
    // RH - 2012-04-19: Added initialisation of Result variable!
    Result := inherited GetDisplayValue;
    if Obj <> nil then
      Result := Result + '(' + Obj.ClassName + ')'
    else
      Result := Result + '(' + GetTypeData(Data.TypeInfo).ClassType.ClassName + ')';
  end
TagsNo tags attached.

Relationships

duplicate of 0005862 resolvedobones TJvInspectorClassItem.GetDisplayValue return value might be invalid (JvInspector) 

Activities

obones

2012-06-11 17:28

administrator   ~0019854

Please provide the zipped sources of a sample application showing this.

RHoek

2012-06-12 15:32

reporter   ~0019918

I don't have a sample which 'shows' the problem, because I've never 'seen' it do something wrong.

I only know for sure, when you use an non-initialized variable (like Result) to set the same variable (or any other variable), you will get strange results at some point!

obones

2012-06-12 16:19

administrator   ~0019928

Except that this is a string variable and I believe that variable to be initialized to an empty string.

RHoek

2012-06-12 16:29

reporter   ~0019930

Hmmm, you're right - never thought of that.

But why the use the syntax 'Result := Result + Newdata;', when no initial data is available?

As far as I'm concerned there's no need to modify the code anymore, other then looking at it from a functional point of view...

obones

2013-12-13 16:16

administrator   ~0020834

Removed the useless copy in GIT

Issue History

Date Modified Username Field Change
2012-04-19 16:34 RHoek New Issue
2012-06-11 17:28 obones Note Added: 0019854
2012-06-11 17:28 obones Status new => feedback
2012-06-12 15:32 RHoek Note Added: 0019918
2012-06-12 16:19 obones Note Added: 0019928
2012-06-12 16:29 RHoek Note Added: 0019930
2013-12-13 11:28 obones Status feedback => acknowledged
2013-12-13 11:28 obones Relationship added duplicate of 0005862
2013-12-13 16:16 obones Note Added: 0020834
2013-12-13 16:16 obones Status acknowledged => resolved
2013-12-13 16:16 obones Fixed in Version => Daily / GIT
2013-12-13 16:16 obones Resolution open => fixed
2013-12-13 16:16 obones Assigned To => obones
2015-09-21 17:47 obones Fixed in Version Daily / GIT => 3.49