UDF crash after 2.5.1 update
----------------------------

                 Key: CORE-3747
                 URL: http://tracker.firebirdsql.org/browse/CORE-3747
             Project: Firebird Core
          Issue Type: Bug
          Components: UDF
    Affects Versions: 2.5.1
         Environment: Windows XP, firebird 2.5, delphi UDF
            Reporter: André Müller Pereira
         Attachments: accessUDF.dll

I have a UDF in FB2.1 used in many clients, without problems.
I'm testing the FB2.5 and with the same UDF and 4 from 6 functions from this 
UDF crash the connection.
I don´t see nothing new in documentation only the FREE_IT, I test but still the 
same problem.

Have some changes that I don't read ?




example:

DECLARE EXTERNAL FUNCTION FormatDate
    TIMESTAMP,
    CSTRING(80)
RETURNS CSTRING(80)
ENTRY_POINT 'FormatDate' MODULE_NAME 'accessUDF';

SQL:
select    IntToDate(45000)     from rdb$database   -->  this function Crash 
connection
select    DateToInt(current_timestamp)  from rdb$database   -->  OK! return 
40939

DELPHI part of code
unit myfuncs;
uses
  SysUtils, DateUtils, ibase, ib_externals, fb_descriptors, math;

function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
...
procedure SetaConfiguracoesRegionais;

implementation
function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
var
  Data: TDateTime;
begin
  Data := isc_decode_TDateTime(ib_date);
  if (Data <  EncodeDate(1899,12,30)) then
  begin
    result := 0;
    Exit;
  end;
  result := DaysBetween(Data,EncodeDate(1899,12,30));
end;

function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
var
  Data: TDateTime;
  v1: Int64;
begin
  if (val1 = nil) or ((val1^.dsc_flags and DSC_null) <> 0) then
  begin
    result := nil;
    Exit;
  end;
  get_int_type(val1, v1);
  Data := EncodeDate(1899,12,30) + v1;
  isc_encode_TDateTime(Data,result);
end;
...
//code from IBO
function isc_decode_TDateTime(const Src: PISC_QUAD): TDateTime;
begin
  Result := Src^.gds_quad_high - 15018;
  try
    Result := Result + EncodeTime((Src^.gds_quad_low div (36000000)),
      (Src^.gds_quad_low div (600000)) mod 60,
      (Src^.gds_quad_low div (10000)) mod 60,
      (Src^.gds_quad_low mod (10000)) div 10);
  except
    Result := Result + 0;
  end;
end;
procedure isc_encode_TDateTime(const Src: TDateTime; const Dst: PISC_QUAD);
var
  Hour, Min, Sec, MSec: word;
begin
  DecodeTime(Src, Hour, Min, Sec, MSec);
  with Dst^ do
  begin
    gds_quad_high := Trunc(Src) + 15018;
    gds_quad_low := Hour * 10000 * 60 * 60 +
      Min * 10000 * 60 +
      Sec * 10000 +
      MSec * 10;
  end;
end;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to