From: Ilia Alshanetsky Date: Mon, 1 Oct 2007 14:53:01 +0000 (+0000) Subject: MFB: Refactor code to make fixes for coverity issues #385 and #386 a bit X-Git-Tag: php-5.2.5RC1~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=191bf235ede5f57ce277ad2ad3ad8457bd2dcf11;p=php MFB: Refactor code to make fixes for coverity issues #385 and #386 a bit more obvious --- diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 55a504f6af..5ff57892e4 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -434,14 +434,16 @@ ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */ tmp_value_len = 0; } - if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) { - value = 1; - } else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) { - value = 1; - } else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) { - value = 1; - } else if (tmp_value) { - value = atoi(tmp_value); + if (tmp_value) { + if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) { + value = 1; + } else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) { + value = 1; + } else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) { + value = 1; + } else (tmp_value) { + value = atoi(tmp_value); + } } else { value = 0; } diff --git a/main/main.c b/main/main.c index bb63051181..6ffc8f71cf 100644 --- a/main/main.c +++ b/main/main.c @@ -218,7 +218,11 @@ static PHP_INI_MH(OnUpdateTimeout) static int php_get_display_errors_mode(char *value, int value_length) { int mode; - + + if (!value) { + return PHP_DISPLAY_ERRORS_STDOUT; + } + if (value_length == 2 && !strcasecmp("on", value)) { mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 3 && !strcasecmp("yes", value)) { @@ -229,14 +233,13 @@ static int php_get_display_errors_mode(char *value, int value_length) mode = PHP_DISPLAY_ERRORS_STDERR; } else if (value_length == 6 && !strcasecmp(value, "stdout")) { mode = PHP_DISPLAY_ERRORS_STDOUT; - } else if (value) { + } else { mode = atoi(value); if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) { mode = PHP_DISPLAY_ERRORS_STDOUT; } - } else { - mode = PHP_DISPLAY_ERRORS_STDOUT; } + return mode; } /* }}} */