Skip to content

Commit 48e22ac

Browse files
committed
Reuse EG(windows_version_info) in php_get_uname()
There is no need to retrieve the Windows OS version information again, since it is already available via `EG(windows_version_info)`.
1 parent fa1af48 commit 48e22ac

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/standard/info.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,10 @@ PHPAPI zend_string *php_get_uname(char mode)
659659
ZEND_ASSERT(php_is_valid_uname_mode(mode));
660660
#ifdef PHP_WIN32
661661
char tmp_uname[256];
662-
DWORD dwBuild=0;
663-
DWORD dwVersion = GetVersion();
664-
DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
665-
DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
662+
OSVERSIONINFOEX osvi = EG(windows_version_info);
663+
DWORD dwWindowsMajorVersion = osvi.dwMajorVersion;
664+
DWORD dwWindowsMinorVersion = osvi.dwMinorVersion;
665+
DWORD dwBuild = osvi.dwBuildNumber;
666666
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
667667
char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
668668

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

681680
ZEND_ASSERT(winver != NULL);
682681

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

695694
php_get_windows_cpu(wincpu, sizeof(wincpu));
696-
dwBuild = (DWORD)(HIWORD(dwVersion));
697695

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

0 commit comments

Comments
 (0)