From 57d8b5b51f7a18fbb9381fe237b961f17ed55e37 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Fri, 23 Sep 2022 14:15:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=9D=A1=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E5=88=B0console=E7=9A=84=E6=97=A5=E5=BF=97=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=89=8D=E7=BC=80#=EF=BC=9Bbool=E5=8F=98=E9=87=8F=E5=88=86?= =?UTF-8?q?=E9=85=8D4=E5=AD=97=E8=8A=82=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/wrapper/hg_log.cpp | 4 ++-- hgsane/sane_hg_mdw.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hgdriver/wrapper/hg_log.cpp b/hgdriver/wrapper/hg_log.cpp index 1b4d9d0..85a911e 100644 --- a/hgdriver/wrapper/hg_log.cpp +++ b/hgdriver/wrapper/hg_log.cpp @@ -619,7 +619,7 @@ extern "C" } if(ind == sizeof(paths) / sizeof(paths[0])) { - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Try PE, scanner and temporary path failed(%d), log to console\n", errno); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "# Try PE, scanner and temporary path failed(%d), log to console\n", errno); type = LOG_TYPE_CONSOLE; } @@ -630,7 +630,7 @@ extern "C" else path += PATH_SEPARATOR + name + ".log"; file = &path[0]; - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Log to file: '%s'\n", path.c_str()); + VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "# Log to file: '%s'\n", path.c_str()); } } log_cls::instance()->set_log_level(level); diff --git a/hgsane/sane_hg_mdw.cpp b/hgsane/sane_hg_mdw.cpp index c467c0b..cf499cc 100644 --- a/hgsane/sane_hg_mdw.cpp +++ b/hgsane/sane_hg_mdw.cpp @@ -99,7 +99,12 @@ namespace local_utility // info = ""; //hg_sane_middleware::log(strlen(info) + 80, "allocate memory with %u bytes from %s\n", bytes, info); - return malloc(bytes); + void* buf = malloc(bytes); + + if (buf) + memset(buf, 0, bytes); + + return buf; } void free_memory(void* m) { @@ -1122,7 +1127,7 @@ void* hg_sane_middleware::get_default_value(scanner_handle handle, int option) bool v = false; jsn->get_value("default", v); - data = local_utility::acquire_memory(sizeof(v), ""); + data = local_utility::acquire_memory(/*sizeof(v)*/4, ""); memcpy(data, &v, sizeof(v)); VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "option %d default value is: %s\n", option, v ? "true" : "false"); }