Skip to content

Commit

Permalink
Reuse EG(windows_version_info) in php_get_uname()
Browse files Browse the repository at this point in the history
There is no need to retrieve the Windows OS version information again,
since it is already available via `EG(windows_version_info)`.
  • Loading branch information
cmb69 committed Jan 25, 2025
1 parent fa1af48 commit 48e22ac
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ext/standard/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,10 @@ PHPAPI zend_string *php_get_uname(char mode)
ZEND_ASSERT(php_is_valid_uname_mode(mode));
#ifdef PHP_WIN32
char tmp_uname[256];
DWORD dwBuild=0;
DWORD dwVersion = GetVersion();
DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
OSVERSIONINFOEX osvi = EG(windows_version_info);
DWORD dwWindowsMajorVersion = osvi.dwMajorVersion;
DWORD dwWindowsMinorVersion = osvi.dwMinorVersion;
DWORD dwBuild = osvi.dwBuildNumber;
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];

Expand All @@ -676,7 +676,6 @@ PHPAPI zend_string *php_get_uname(char mode)
php_uname = ComputerName;
} else if (mode == 'v') {
char *winver = php_get_windows_name();
dwBuild = (DWORD)(HIWORD(dwVersion));

ZEND_ASSERT(winver != NULL);

Expand All @@ -693,7 +692,6 @@ PHPAPI zend_string *php_get_uname(char mode)
ZEND_ASSERT(winver != NULL);

php_get_windows_cpu(wincpu, sizeof(wincpu));
dwBuild = (DWORD)(HIWORD(dwVersion));

/* Windows "version" 6.2 could be Windows 8/Windows Server 2012, but also Windows 8.1/Windows Server 2012 R2 */
if (dwWindowsMajorVersion == 6 && dwWindowsMinorVersion == 2) {
Expand Down

0 comments on commit 48e22ac

Please sign in to comment.