com php-src: fix possible null dereference: win32/codepage.c

From: Date: Wed, 21 Dec 2016 16:58:34 +0000
Subject: com php-src: fix possible null dereference: win32/codepage.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96403@lists.php.net to get a copy of this message
Commit: 637436628adc0c3c28d712be37902cb715c8a0b4 Author: Anatol Belski <ab@php.net> Wed, 21 Dec 2016 17:58:34 +0100 Parents: 82988d3e419c4537e6e5db30c4ea511c4abf29f6 Branches: PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=637436628adc0c3c28d712be37902cb715c8a0b4 Log: fix possible null dereference Changed paths: M win32/codepage.c Diff: diff --git a/win32/codepage.c b/win32/codepage.c index 519ff03..0cedda8 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;

« previous php.cvs (#96403) next »