summaryrefslogtreecommitdiff
path: root/library/Console-windows.cpp
diff options
context:
space:
mode:
authorPetr Mrázek2011-07-14 08:02:29 +0200
committerPetr Mrázek2011-07-14 08:02:29 +0200
commitf2b46274ec15b81fc49c393302bad26bf80d63b1 (patch)
treef0ac5c26eeb81b780f47608c5dfbacec38851c9c /library/Console-windows.cpp
parent96153a7b05e7ecfaa0f2c4ab744ae3c71144ff41 (diff)
downloaddfhack-f2b46274ec15b81fc49c393302bad26bf80d63b1.tar.gz
dfhack-f2b46274ec15b81fc49c393302bad26bf80d63b1.tar.bz2
dfhack-f2b46274ec15b81fc49c393302bad26bf80d63b1.tar.xz
Fix for a bug in command history queue access. dfhack script can run valgrind.
Diffstat (limited to 'library/Console-windows.cpp')
-rw-r--r--library/Console-windows.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/library/Console-windows.cpp b/library/Console-windows.cpp
index 8c148093..e0c0fc17 100644
--- a/library/Console-windows.cpp
+++ b/library/Console-windows.cpp
@@ -83,7 +83,7 @@ namespace DFHack
Console::Console():std::ostream(0), std::ios(0)
{
- d = new Private();
+ d = 0;
}
Console::~Console()
@@ -92,6 +92,7 @@ Console::~Console()
bool Console::init(void)
{
+ d = new Private();
int hConHandle;
long lStdHandle;
CONSOLE_SCREEN_BUFFER_INFO coninfo;
@@ -267,10 +268,10 @@ int Console::prompt_loop(const std::string & prompt, std::string & buffer)
size_t plen = prompt.size();
size_t pos = 0;
int history_index = 0;
-
/* The latest history entry is always our current buffer, that
* initially is just an empty string. */
- history_add("");
+ const std::string empty;
+ history_add(empty);
CONSOLE_SCREEN_BUFFER_INFO inf = { 0 };
GetConsoleScreenBufferInfo(d->console_out, &inf);