----------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - CLOSE THE FILE HANDLE AFTER THE FILETOSTR() FUNCTION FAILED
                                  June 2024
                 ----------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), sometimes vfp will not close the file handle after the FILETOSTR() function failed.

     The bug was reported by Mrs Martina Jindrova.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label58dab7 ::


     ;
     ;                 -----------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - CLOSE THE FILE HANDLE AFTER THE FILETOSTR() FUNCTION FAILED
     ;                                  June 2024
     ;                 -----------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Close the file handle after the FILETOSTR() function failed.
     ;
     ; 2024/6/3, by ccb
     ;

             cmp dword ptr vfpa_sys9157_data,00h
             je Label58dab8
             cmp dword ptr [ esp + 4 ] , offset Label488e1a ;; Label488d4b ::
             jne Label58dab8
             jmp Label58dabf


     Label58dab8 ::
             test  byte ptr [ Data936f10 ] , bl                              ;0x0058dab7 :        841d106f9300
             je Label58dae3                                                  ;0x0058dabd :        7424

     Label58dabf ::
             mov eax ,  dword ptr [ Data936f14 ]                             ;0x0058dabf :        a1146f9300
             test eax , eax                                                  ;0x0058dac4 :        85c0
             jne Label58daed                                                 ;0x0058dac6 :        7525
             mov  dword ptr [ esi + 4 ] , ebx                                ;0x0058dac8 :        895e04
             mov  dword ptr [ Data936f14 ] , 0B6h                            ;0x0058dacb :        c705146f9300b6000000
             mov  byte ptr [esi] , 049h                                      ;0x0058dad5 :        c60649
             mov  dword ptr [ esi + 12 ] , 00h                               ;0x0058dad8 :        c7460c00000000
             xor eax , eax                                                   ;0x0058dadf :        33c0
             pop ebx                                                         ;0x0058dae1 :        5b
             ret                                                             ;0x0058dae2 :        c3


4. APPLIES TO:

     VFP 6.0.8167.0
     VFP 6.0.8961.0 (SP5)

     VFP 7.0.0.9262
     VFP 7.0.0.9465 (SP1)

     VFP 8.0.0.2521
     VFP 8.0.0.3117 (SP1)

     VFP 9.0.0.2412
     VFP 9.0.0.3504 (SP1)
     VFP 9.0.0.4611 (SP2)
     VFP 9.0.0.5015 (SP2)
     VFP 9.0.0.5411 (SP2)
     VFP 9.0.0.5721 (SP2)
     VFP 9.0.0.5815 (SP2)
     VFP 9.0.0.6303 (SP2)
     VFP 9.0.0.6602 (SP2)
     VFP 9.0.0.7423 (SP2)

     The bug has been fixed in VFP Advanced.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix324.asp


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.