[Done] 6.40 b1 - FileSize() returns incorrect result

Post bugreports for the Windows version here
breeze4me
Enthusiast
Enthusiast
Posts: 680
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

[Done] 6.40 b1 - FileSize() returns incorrect result

Post by breeze4me »

The string modification function called first within the FileSize() function does not set the string length.
This seems to be why incorrect values like the ones below are being returned.

BTW, it appears that within the FileSize() function, the string length is read from the 4 bytes(x86) preceding the memory address allocated by HeapAlloc.

Code: Select all

short * FUN_14000187c(short *Filename)
{
  short *psVar1;
  short *psVar2;
  longlong lVar3;
  
  psVar1 = (short *)0x0;
  if ((Filename != (short *)0x0) && (psVar1 = (short *)0x0, *Filename != 0)) {
    lVar3 = *(longlong *)(Filename + -4) * 2 >> 1;
    psVar1 = HeapAlloc(DAT_14003ee10,0,lVar3 * 2 + 0x22);
    if (psVar1 != (short *)0x0) {
      FUN_140001ca8(psVar1,Filename);
      for (psVar2 = psVar1 + lVar3 + -1;
          (psVar1 <= psVar2 && ((*psVar2 == L'\\' || (*psVar2 == L'/')))); psVar2 = psVar2 + -1) {
        *psVar2 = 0;
      }
    }
  }
  return psVar1;
}
Results for 6.30 and earlier.

Code: Select all

Debug FileSize("c:\")
Debug FileSize("d:\")
Debug FileSize("e:\")
Debug FileSize("z:\")

; -2
; -2
; -2
; -2
Results for 6.40 b1

Code: Select all

Debug FileSize("c:\")
Debug FileSize("d:\")
Debug FileSize("e:\")
Debug FileSize("z:\")

; -2
; -1
; -1
; -1
Fred
Administrator
Administrator
Posts: 18558
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [6.40 b1] FileSize() returns incorrect result

Post by Fred »

Fixed.
Post Reply