summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-12-21 17:58:34 +0100
committerAnatol Belski <ab@php.net>2016-12-21 17:58:34 +0100
commit637436628adc0c3c28d712be37902cb715c8a0b4 (patch)
treeb064164768ea666d01e392950f8775fa747c4399
parent82988d3e419c4537e6e5db30c4ea511c4abf29f6 (diff)
downloadphp-git-637436628adc0c3c28d712be37902cb715c8a0b4.tar.gz
fix possible null dereference
-rw-r--r--win32/codepage.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/win32/codepage.c b/win32/codepage.c
index 519ff03f4b..0cedda8f71 100644
--- a/win32/codepage.c
+++ b/win32/codepage.c
@@ -498,16 +498,18 @@ PW32CP const struct php_win32_cp *php_win32_cp_cli_do_setup(DWORD id)
PW32CP const struct php_win32_cp *php_win32_cp_cli_do_restore(DWORD id)
{/*{{{*/
- if (!id && orig_cp) {
- id = orig_cp->id;
+ BOOL cli_io_restored = TRUE;
+
+ if (orig_in_cp) {
+ cli_io_restored = cli_io_restored && SetConsoleCP(orig_in_cp->id);
}
- if (SetConsoleCP(orig_in_cp->id) && SetConsoleOutputCP(orig_out_cp->id)) {
- if (orig_cp) {
- return orig_cp;
- } else {
- return php_win32_cp_set_by_id(id);
- }
+ if (orig_out_cp) {
+ cli_io_restored = cli_io_restored && SetConsoleOutputCP(orig_out_cp->id);
+ }
+
+ if (cli_io_restored && id) {
+ return php_win32_cp_set_by_id(id);
}
return NULL;