修复内存泄漏

This commit is contained in:
gb 2022-11-19 08:48:39 +08:00
parent 46f43ebd0d
commit bb4c3ce55a
2 changed files with 12 additions and 5 deletions

View File

@ -1124,7 +1124,8 @@ bool scanner::set_option_value_with_parent(int sn, void* data, int* err) // retu
strcpy(val, OPTION_VALUE_SMZS_LXSM);
*err = hg_sane_middleware::instance()->set_option(handle_, scan_mode_id_, SANE_ACTION_SET_VALUE, val, &after);
}
handled = false;
delete[] val;
// handled = false;
}
else
{
@ -2461,11 +2462,14 @@ COM_API_IMPLEMENT(scanner, int, set_value(int sn, void* val))
SANE_Option_Descriptor* desc = hg_sane_middleware::instance()->get_option_descriptor(handle_, sn);
{
wchar_t msg[128] = { 0 };
wchar_t msg[256] = { 0 };
if (ex == ex_opts_.end())
swprintf_s(msg, _countof(msg) - 1, L"set_value of ID: %d\r\n", sn);
swprintf_s(msg, _countof(msg) - 1, L"set_value of %s(%s) of ID %d\r\n", local_trans::a2u(desc->name, CP_UTF8).c_str(), local_trans::a2u(hg_sane_middleware::option_value_2_string(desc->type, val).c_str(), CP_UTF8).c_str(), sn);
else
swprintf_s(msg, _countof(msg) - 1, L"set_value of ID: %d (base id = %d)\r\n", sn, ex->base_ind);
{
desc = hg_sane_middleware::instance()->get_option_descriptor(handle_, ex->base_ind);
swprintf_s(msg, _countof(msg) - 1, L"set_value of %s(0x%x) of ID %d, base id = %d)\r\n", local_trans::a2u(desc->name, CP_UTF8).c_str(), *(unsigned*)val, sn, ex->base_ind);
}
log_info(msg, 0);
}

View File

@ -1748,7 +1748,10 @@ void huagao_ds::init_support_caps(void)
init = (int)data.currentItem<CapType::IPixelType>();
{
wchar_t info[128] = { 0 }, * des[] = { L"BlackWhite", L"Gray", L"Rgb" };
if((int)init < _countof(des))
swprintf_s(info, _countof(info) - 1, L"set CapType::IPixelType = %s\r\n", des[(int)init]);
else
swprintf_s(info, _countof(info) - 1, L"set CapType::IPixelType = 0x%x\r\n", (int)init);
load_sane_util::log_info(info, 0);
}
int ret = SCANNER_ERR_OK;