Make it safe to call close_file on an already closed file. syslinux-3.50-pre15
authorH. Peter Anvin <hpa@zytor.com>
Wed, 23 May 2007 06:27:46 +0000 (23:27 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 23 May 2007 06:27:46 +0000 (23:27 -0700)
The SYSLINUX internal API closes a file automatically upon reading
to block EOF (not necessarily file EOF!)  Thus, it's fairly likely
we'll get SI == 0 (closed file) passed to close_file at some point
or another.

Just plain admit it, and make close_file accept SI == 0 by spec.

comboot.inc
extlinux.asm
getc.inc
isolinux.asm
ldlinux.asm
pxelinux.asm

index 4896e39..034f924 100644 (file)
@@ -434,10 +434,7 @@ comapi_read:
 ;
 comapi_close:
                mov si,P_SI
-               and si,si
-               jz .nothing
                call close_file
-.nothing:
                clc
                ret
 
index 7d73507..a590a36 100644 (file)
@@ -1039,8 +1039,10 @@ ThisInode        resb EXT2_GOOD_OLD_INODE_SIZE   ; The most recently opened inode
 ;           Assumes CS == DS.
 ;
 close_file:
+               and si,si
+               jz .closed
                mov dword [si],0                ; First dword == file_left
-               ret
+.closed:       ret
 
 ;
 ; searchdir:
index 610d01b..5c8dc86 100644 (file)
--- a/getc.inc
+++ b/getc.inc
@@ -162,9 +162,6 @@ close:
                push si
                mov bx,[CurrentGetC]
                mov si,[bx+gc_file]
-               and si,si
-               jz .closed
-.closed:
                call close_file
                add bx,getc_file_size
                mov [CurrentGetC],bx
index de4f164..f9e8741 100644 (file)
@@ -1143,8 +1143,10 @@ local_boot:
 ;           Assumes CS == DS.
 ;
 close_file:
+               and si,si
+               jz .closed
                mov dword [si],0                ; First dword == file_left
-               ret
+.closed:       ret
 
 ;
 ; searchdir:
index 7d7b8f2..eed2951 100644 (file)
@@ -1065,8 +1065,10 @@ search_dos_dir:
 ;           Assumes CS == DS.
 ;
 close_file:
+               and si,si
+               jz .closed
                mov dword [si],0                ; First dword == file_left
-               ret
+.closed:       ret
 
 ;
 ; searchdir:
index 253aa0f..3e50245 100644 (file)
@@ -1078,8 +1078,10 @@ memory_scan_for_pxenv_struct:
 ; side and send a courtesy ERROR packet to the server.
 ;
 close_file:
+               and si,si
+               jz .closed
                mov word [si],0         ; Not in use
-               ret
+.closed:       ret
 
 ;
 ; searchdir: