llde / xOBSE

Oblivion Script extender source
252 stars 36 forks source link

Crashes when specifying a path containing multibyte characters in the FileExists function #237

Open rnruxn773 opened 1 day ago

rnruxn773 commented 1 day ago

Since xOBSE-22.10beta2, specifying a path containing non-alphanumeric multibyte characters such as Chinese or Russian in the FileExists function causes an immediate crash.

The issue can be reproduced with the following code:

scn testquestscript

string_var filepath

Begin GameMode

    if GetGameLoaded
        let filepath := "Data\ini.ini"

        ; Passed
        printc "check 1 : %z" filepath
        if FileExists $filepath
            printc "check 1 : %z found!" filepath
        endif

        let filepath := "Data\ini_к файлу_文件路径.ini"

        ; Not passed
        printc "check 2 : %z" filepath
        if FileExists $filepath
            printc "check 2 : %z found!" filepath
        endif

        sv_Destruct filepath
    endif
End
llde commented 15 hours ago

I'm afraid you are mixing characters from 2 different locales, I'm not sure how conversion function for CP_ACP codepage can react. I Will try to not make the function crash however. A workaround may be, maybe, to use directly the complete string instead of composing ti with stringvars.

rnruxn773 commented 12 hours ago

Sorry for the confusion, but mixing characters from two different locales was just an example for the sample code. In reality, the function should crash if it contains any multibyte characters, regardless of the locale. My Win 11 is set to the Japanese locale, and I've confirmed that it crashes even when only Japanese characters are included. This happens with or without the Japanese localization patch (OBJA).

I've attached the ESP plugin for the code mentioned above, so please check it if needed. FileExists_test.zip

llde commented 4 hours ago

Hi, I reproduced the crash with the sample script, I had to force japanese locale on my end too. Crash happens inside DoStringExtractHook.