Skip to content

Commit

Permalink
Fix quotes on Windows.
Browse files Browse the repository at this point in the history
Boost process wchar_t conversion chokes if it's fed an empty string.
This would happen when the user had no alphavantage key. Separate
the process invocation to not present the empty value to boost process.
  • Loading branch information
jralls committed Mar 19, 2023
1 parent 90e1e2d commit 576fc9b
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions libgnucash/app-utils/gnc-quotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,23 @@ GncFQQuoteSource::run_cmd (const StrVec& args, const std::string& json_string) c
boost::asio::io_service svc;

auto input_buf = bp::buffer (json_string);
bp::child process (c_cmd, args,
bp::std_out > out_buf,
bp::std_err > err_buf,
bp::std_in < input_buf,
bp::env["ALPHAVANTAGE_API_KEY"]= (m_api_key.empty() ? "" : m_api_key),
svc);
svc.run();
process.wait();
bp::child process;
if (m_api_key.empty())
process = bp::child(c_cmd, args,
bp::std_out > out_buf,
bp::std_err > err_buf,
bp::std_in < input_buf,
svc);
else
process = bp::child(c_cmd, args,
bp::std_out > out_buf,
bp::std_err > err_buf,
bp::std_in < input_buf,
bp::env["ALPHAVANTAGE_API_KEY"] = m_api_key,
svc);

svc.run();
process.wait();

{
auto raw = out_buf.get();
Expand Down

0 comments on commit 576fc9b

Please sign in to comment.