Skip to content

Commit 9cb582c

Browse files
Merge pull request #1 from Tavel/master
Fixed use of uninitialized local variable "loc" which caused unwanted.
2 parents cce291d + f12d779 commit 9cb582c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

IP2Location.pas

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,14 +646,19 @@ function read_record(loc:TIP2Location;rowaddr,mode:cardinal):TIP2LocationRecord;
646646
// Description: Open the IP2Location database file
647647
function IP2Location_open(db:PChar):TIP2Location;
648648
var f:integer;
649-
var loc:TIP2Location;
649+
loc:TIP2Location;
650650
begin
651+
FillChar(loc, SizeOf(TIP2Location), #0);
652+
653+
Result := loc;
654+
651655
f:=FileOpen(db,fmOpenRead);
652656
if f <> INVALID_HANDLE_VALUE then
653657
begin
654-
result.filehandle:=f;
655-
IP2Location_initialize(result);
658+
loc.filehandle:=f;
659+
IP2Location_initialize(loc);
656660
if loc.productcode = 1 then
661+
Result := loc
657662
else
658663
if ((loc.databaseyear <= 20) and (loc.productcode = 0)) then
659664
begin

0 commit comments

Comments
 (0)