-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JclSysInfo causing programs freeze under Win8.1 #116
base: master
Are you sure you want to change the base?
Conversation
Under Windows 8.1 Embedded Industrial Enterprice (Build 9600) the GetWindowsMajorVersionNumber() causing: `EConvertError: '' is not a valid integer value.` It is reckless to call unsafe code from initialization part!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is now in UTF-8 encoding and should be ANSI encoding
I've clicked only the "Edit" here on github and edited. |
@PizzaProgram yes, that's a known thing. |
The StrToInt code in GetWindowsMajorVersionNumber was changed to StrToIntDef in August 2016. |
@ahausladen jcl/jcl/source/common/JclSysInfo.pas Line 4167 in 47af4fe
That code is unsafe this way.
I haven't searched the entire unit, but I guess there are other functions like this too. |
@ronaldhoek |
This pull request fixes the symptoms by catching all exceptions. It would be better to fix the actual cause. The StrToIntDef that was added in 2016 prevents the EConvertError. So I made the assumption that the code base you used may have been too old. About the GetWindowsMajorVersionNumber:
GetWindowsMinorVersionNumber:
I found another StrToInt call in GetWindowsBuildNumber that could throw an EConvertError if the "CurrentBuildNumber" registry value exists but isn't a number. |
IMHO if there is no point, it should still try to convert from string to int to get the major version number. The decimal point is only a must to get the Minor version. |
Also, my opinion stays:
There should be always a try - except at init.. and finalization part !It is not fair, to write a component, that can freeze an app before it can even start.
|
…eeze under Win8.1 - Replaces StrToInt with StrToIntDef - Fixes possible wrong major version (returned 2 instead of Win32MajorVersion, returned 2 if the version number didn't contain a dot instead of the whole version number as major version) - Added try/except blocks
I've made a commit that combines the cause-fixes and adds the try/except blocks in the InitSysInfo and FinalizeSysInfo functions. |
Under Windows 8.1 Embedded Industrial Enterprice (Build 9600) the GetWindowsMajorVersionNumber() causing:
EConvertError: '' is not a valid integer value.
It is reckless to call unsafe code from initialization part!