diff --git a/sane/DlgPage.cpp b/sane/DlgPage.cpp index 994149c..04cc8b3 100644 --- a/sane/DlgPage.cpp +++ b/sane/DlgPage.cpp @@ -889,10 +889,9 @@ void* dlg_page::value_from_ctrl(HWND ctrl, SANE_Value_Type* type) else if (cmpstr(cls, WC_EDITW) == 0 || cmpstr(cls, WC_COMBOBOXW) == 0) { int len = (int)GetPropW(host, dlg_page::property_size.c_str()); - wchar_t* buf = new wchar_t[len + 2]; + wchar_t* buf = new wchar_t[len + 8]; - GetWindowTextW(ctrl, buf, len); - buf[len] = 0; + GetWindowTextW(ctrl, buf, len + 6); if (tp == SANE_TYPE_INT) { ret = new char[sizeof(SANE_Int)]; @@ -905,6 +904,7 @@ void* dlg_page::value_from_ctrl(HWND ctrl, SANE_Value_Type* type) } else if (tp == SANE_TYPE_STRING) { + buf[len] = 0; std::string utf8(local_trans::u2a(buf, CP_UTF8)); ret = new char[len + 2]; if ((int)utf8.length() > len) diff --git a/sane/gb_json.cpp b/sane/gb_json.cpp index b7d5eb9..d4545c1 100644 --- a/sane/gb_json.cpp +++ b/sane/gb_json.cpp @@ -3,6 +3,8 @@ #include #include +#include "../../sdk/include/huagao/brand.h" + #if defined(WIN32) || defined(_WIN64) #define bzero(b, s) memset(b, 0, s) #endif @@ -1067,6 +1069,12 @@ namespace gb { if (jsn_) { + { + char ver[40] = { 0 }; + sprintf_s(ver, "%u.%u", VERSION_MAIN, VERSION_SUB); + jsn_->set_value("ver", ver); + } + std::string cont(jsn_->to_string(false)), encode(""); gb::base64 b64; diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 500fa54..c6f676e 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -979,6 +979,8 @@ EX_OPTION_HANDLER_IMPL(paper) int now = sane_opt_trans::paper_to_twain(buf), init = sane_opt_trans::paper_to_twain(def), val = 0; + + local_utility::free_memory(def); do { if (desc->constraint_type == SANE_CONSTRAINT_STRING_LIST) @@ -1176,6 +1178,7 @@ EX_OPTION_HANDLER_IMPL(duplex) setv(&val, VAL_ROLE_DEFAULT, data); } } + local_utility::free_memory(init); } else { diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index c0a76fc..31ab83e 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -444,6 +444,14 @@ static void copy_type(bool& to, Bool from) { to = (bool)from; } +static void copy_type(BYTE& to, bool from) +{ + to = from; +} +static void copy_type(bool& to, BYTE from) +{ + to = (bool)from; +} static void copy_type(UInt32& to, int from) { to = from; @@ -2683,7 +2691,7 @@ void huagao_ds::init_support_caps_ex(void) { \ if(type == VAL_TYPE_BOOL) \ { \ - SET_SANE_CAP(bool, Bool, name) \ + SET_SANE_CAP(bool, BYTE, name) \ } \ else if(type == VAL_TYPE_INT) \ { \