diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index a19b83fb..75a90681 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -523,9 +523,9 @@ function tar_file($filename, $tmp_file) { function ini_bytes($ini) { $val = ini_get($ini); switch (strtolower(substr($val, -1))) { - case 'g': $val *= 1024; // no break - case 'm': $val *= 1024; // no break - case 'k': $val *= 1024; + case 'g': $val = (int)$val * 1024; // no break + case 'm': $val = (int)$val * 1024; // no break + case 'k': $val = (int)$val * 1024; } return $val; } diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 1794aaa1..526f8c06 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -32,8 +32,8 @@ if (!$error && $_POST) { } if (is_string($query)) { // get_file() returns error as number, fread() as false - if (function_exists('memory_get_usage')) { - @ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables + if (function_exists('memory_get_usage') && ($memory_limit = ini_bytes("memory_limit")) != "-1") { + @ini_set("memory_limit", max($memory_limit, 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables } if ($query != "" && strlen($query) < 1e6) { // don't add big queries