#565 BugFixed: Npp may crash when sorting files by clicking at path column in [windows-windows] dialog with opened files having non-ascii characters in path

Next_release
closed
nobody
None
9
2014-03-07
2014-02-21
visimulator
No

BugFixed Npp may crash when sorting files by clicking at the path column in [windows->windows] dialog in the situation
there are non-ascii characters (e.g. directories in chinese) in the path of files opened in npp.
I test it with about 40 files opened, within which there are two files having non-ascii characters in their directories.

the diff:

diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp
index 49829bb..411b035 100644
--- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp
+++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp
@@ -85,30 +85,39 @@ struct NumericStringEquivalence
static int numstrcmp(const TCHAR str1, const TCHAR str2)
{
TCHAR p1, p2;
- int c1, c2, lcmp;
+ int c1, c2, lcmp = 0;
for(;;)
{
- c1 = tolower(str1), c2 = tolower(str2);
- if ( c1 == 0 || c2 == 0 )
+ if (str1 == 0 || str2 == 0) {
+ if (str1 != str2)
+ lcmp = str1 - str2;
break;
- else if (isdigit(c1) && isdigit(c2))
+ }
+ if (_istdigit(str1) && _istdigit(str2))
{
lcmp = generic_strtol(str1, &p1, 10) - generic_strtol(str2, &p2, 10);
if ( lcmp == 0 )
lcmp = (p2 - str2) - (p1 - str1);
if ( lcmp != 0 )
- return (lcmp > 0 ? 1 : -1);
+ break;
str1 = p1, str2 = p2;
}
- else
+ else
{
+ if (_istascii(str1) && _istupper(str1))
+ c1 = _totlower(str1);
+ else
+ c1 =
str1;
+ if (_istascii(str2) && _istupper(str2))
+ c2 = _totlower(str2);
+ else
+ c2 =
str2;
lcmp = (c1 - c2);
if (lcmp != 0)
- return (lcmp > 0 ? 1 : -1);
+ break;
++str1, ++str2;
}
}
- lcmp = (c1 - c2);
return ( lcmp < 0 ) ? -1 : (lcmp > 0 ? 1 : 0);
}
};
-----------

1 Attachments

Discussion

  • Don HO

    Don HO - 2014-02-21

    Thank you for the patch.

    Could you provide the instruction to make crash?
    Without reproduction of crash, there's no way to prove the patch fix the crash and I cannot integrate your fix.

    Don

     
  • visimulator

    visimulator - 2014-02-22

    Thank you very much for all of your work with NPP.

    and the steps to make npp crash by sorting files as below:

    PLEASE PAY ATTENTION: the following operations may lead your windows system frozen, after that, you have to logoff (by ctrl-alt-del) and re-login windows to stop the frozen npp, the process manager (process explorer on my system) can't work. so please save your work before follow it or test it in a virtual machine.

    In the 7zip file attached, there are a directory and two empty files under it. all names are in chinese. unzip the 7zip file in the root of a disk volume, and open the two empty files with NPP.

    Now, click at menu [windows->windows...] to open file list dialog window, and you can see two files in file list. click at the path column (2nd column), npp wiil get frozen, after a while, the windows system will frozen.

    My test environment:
    npp 5.3.1 (language in english)
    Windows 8 x64 simple Chinese edition.

     
    Last edit: visimulator 2014-02-22
    • Don HO

      Don HO - 2014-02-23

      Thank you for all info. The crash is reproducible.
      Your patch has been committed in SVN.

      Don

       
  • Don HO

    Don HO - 2014-02-23
    • status: open --> accepted
    • Priority: 5 --> 9
     
  • Don HO

    Don HO - 2014-03-07
    • Status: accepted --> closed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks