diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-07-23 10:51:19 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-07-23 10:51:19 +0200 |
commit | 3365f28adf90110ca7475df889720fc244820f4b (patch) | |
tree | 5415edde3e396a93f05f887d9f07071871467bdf /win32 | |
parent | f0f8d7084aec4be5c07f02f2e29c2820f85c8315 (diff) | |
download | php-3365f28adf90110ca7475df889720fc244820f4b.tar.gz |
Imported Upstream version 5.4.5upstream/5.4.5
Diffstat (limited to 'win32')
-rw-r--r-- | win32/registry.c | 12 | ||||
-rw-r--r-- | win32/time.c | 18 |
2 files changed, 23 insertions, 7 deletions
diff --git a/win32/registry.c b/win32/registry.c index 35b411f4c..45e842b45 100644 --- a/win32/registry.c +++ b/win32/registry.c @@ -77,11 +77,16 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_ value_len = max_value+1; if (RegEnumValue(key, i, name, &name_len, NULL, &type, value, &value_len) == ERROR_SUCCESS) { if ((type == REG_SZ) || (type == REG_EXPAND_SZ)) { + ht = (HashTable*)malloc(sizeof(HashTable)); if (!ht) { - ht = (HashTable*)malloc(sizeof(HashTable)); - zend_hash_init(ht, 0, NULL, ZVAL_INTERNAL_PTR_DTOR, 1); + return ret; } + zend_hash_init(ht, 0, NULL, ZVAL_INTERNAL_PTR_DTOR, 1); + data = (zval*)malloc(sizeof(zval)); + if (!data) { + return ret; + } INIT_PZVAL(data); Z_STRVAL_P(data) = zend_strndup(value, value_len-1); Z_STRLEN_P(data) = value_len-1; @@ -174,6 +179,9 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC) if (!PW32G(registry_directories)) { PW32G(registry_directories) = (HashTable*)malloc(sizeof(HashTable)); + if (!PW32G(registry_directories)) { + return; + } zend_hash_init(PW32G(registry_directories), 0, NULL, delete_internal_hashtable, 1); if (!OpenPhpRegistryKey("\\Per Directory Values", &PW32G(registry_key))) { PW32G(registry_key) = NULL; diff --git a/win32/time.c b/win32/time.c index a376fd61b..391a8a81e 100644 --- a/win32/time.c +++ b/win32/time.c @@ -1,4 +1,3 @@ - /***************************************************************************** * * * DH_TIME.C * @@ -35,12 +34,21 @@ int getfilesystemtime(struct timeval *time_Info) { -FILETIME ft; -__int64 ff; + FILETIME ft; + __int64 ff; + ULARGE_INTEGER convFromft; GetSystemTimeAsFileTime(&ft); /* 100 ns blocks since 01-Jan-1641 */ - /* resolution seems to be 0.01 sec */ - ff = *(__int64*)(&ft); + /* resolution seems to be 0.01 sec */ + /* + * Do not cast a pointer to a FILETIME structure to either a + * ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows. + * via http://technet.microsoft.com/en-us/library/ms724284(v=vs.85).aspx + */ + convFromft.HighPart = ft.dwHighDateTime; + convFromft.LowPart = ft.dwLowDateTime; + ff = convFromft.QuadPart; + time_Info->tv_sec = (int)(ff/(__int64)10000000-(__int64)11644473600); time_Info->tv_usec = (int)(ff % 10000000)/10; return 0; |