diff --git a/components/fpdebug/fpdbgdwarf.pas b/components/fpdebug/fpdbgdwarf.pas index f36598f6e7..3164f06993 100644 --- a/components/fpdebug/fpdbgdwarf.pas +++ b/components/fpdebug/fpdbgdwarf.pas @@ -3373,17 +3373,22 @@ begin Result := RefSymbol <> nil; if Result then begin ValObj := RefSymbol.Value; - assert(ValObj is TFpValueDwarfBase, 'Result is TFpValueDwarfBase'); - TFpValueDwarfBase(ValObj).Context := AValueObj.Context; - AValue := ValObj.AsInteger; - if IsError(ValObj.LastError) then begin - Result := False; - SetLastError(AValueObj, ValObj.LastError); - end; - ValObj.ReleaseReference; + Result := ValObj <> nil; + if Result then begin + assert(ValObj is TFpValueDwarfBase, 'Result is TFpValueDwarfBase'); + TFpValueDwarfBase(ValObj).Context := AValueObj.Context; + AValue := ValObj.AsInteger; + if IsError(ValObj.LastError) then begin + Result := False; + SetLastError(AValueObj, ValObj.LastError); + end; + ValObj.ReleaseReference; - if ADataSymbol <> nil then - ADataSymbol^ := RefSymbol + if ADataSymbol <> nil then + ADataSymbol^ := RefSymbol + else + RefSymbol.ReleaseReference; + end else RefSymbol.ReleaseReference; end; @@ -3614,7 +3619,8 @@ begin if sym <> nil then begin assert(sym is TFpSymbolDwarfData, 'TFpSymbolDwarf.GetNestedValue: sym is TFpSymbolDwarfData'); Result := TFpValueDwarf(sym.Value); - Result.FParentTypeSymbol := OuterSym; + if Result <> nil then + Result.FParentTypeSymbol := OuterSym; end else Result := nil; @@ -3629,7 +3635,8 @@ begin if sym <> nil then begin assert(sym is TFpSymbolDwarfData, 'TFpSymbolDwarf.GetNestedValueByName: sym is TFpSymbolDwarfData'); Result := TFpValueDwarf(sym.Value); - Result.FParentTypeSymbol := OuterSym; + if Result <> nil then + Result.FParentTypeSymbol := OuterSym; end else Result := nil; @@ -5450,8 +5457,10 @@ begin InfoEntry.IsArtificial then begin Result := TFpValueDwarf(TFpSymbolDwarfData.CreateValueSubClass('self', InfoEntry).Value); - Result.FDataSymbol.ReleaseReference; - Result.FDataSymbol.LocalProcInfo := Self; + if Result <> nil then begin + Result.FDataSymbol.ReleaseReference; + Result.FDataSymbol.LocalProcInfo := Self; + end; debugln(FPDBG_DWARF_SEARCH, ['TFpSymbolDwarfDataProc.GetSelfParameter ', InfoEntry.ScopeDebugText, DbgSName(Result)]); end; end; diff --git a/components/fpdebug/fpdbgdwarffreepascal.pas b/components/fpdebug/fpdbgdwarffreepascal.pas index 39bfc101c3..7aca839d2a 100644 --- a/components/fpdebug/fpdbgdwarffreepascal.pas +++ b/components/fpdebug/fpdbgdwarffreepascal.pas @@ -515,6 +515,10 @@ begin ParentFpSym := TFpSymbolDwarf.CreateSubClass(AName, InfoEntry); ParentFpVal := ParentFpSym.Value; + if ParentFpVal = nil then begin + Result := False; + exit; + end; ApplyContext(ParentFpVal); if not (svfOrdinal in ParentFpVal.FieldFlags) then begin DebugLn(FPDBG_DWARF_VERBOSE, 'no ordinal for parentfp'); @@ -1016,18 +1020,20 @@ begin UpperBoundSym := TFpSymbolDwarf.CreateSubClass('', Info); if UpperBoundSym <> nil then begin val := UpperBoundSym.Value; - TFpValueDwarf(val).Context := Context; - h := Val.AsInteger; - val.ReleaseReference; - if (h >= 0) and (h < maxLongint) then begin - Result := h + 1; - end - else - Result := 0; -// TODO h < -1 => Error - Info.ReleaseReference; - UpperBoundSym.ReleaseReference; - exit; + if val <> nil then begin + TFpValueDwarf(val).Context := Context; + h := Val.AsInteger; + val.ReleaseReference; + if (h >= 0) and (h < maxLongint) then begin + Result := h + 1; + end + else + Result := 0; + // TODO h < -1 => Error + Info.ReleaseReference; + UpperBoundSym.ReleaseReference; + exit; + end; end; end; end;