Menu

#24 Checking Imput on functions like GetCatalogName

open
nobody
None
2021-01-26
2021-01-26
No

While doing work on the Webservice Proxy, I stumbeled upon this implementation:

function TZAbstractResultSetMetadata.GetCatalogName(ColumnIndex: Integer): string;
begin
  if not Loaded then
     LoadColumns;
  Result := TZColumnInfo(FResultSet.ColumnsInfo[ColumnIndex {$IFNDEF GENERIC_INDEX}-1{$ENDIF}]).CatalogName;
end;

For ease of use, I first implemented column indices to be queried from 1 until ColumnCount and didn't use FirstDbcIndex. The error is clear - as soon as the GENERIC_INDEX defin is set, this doesn't work.

So - I wonder - since this is part of the public API - shouldn't we check the input and raise exceptions when the index is out of bounds?

Discussion


Log in to post a comment.