]> git.tdb.fi Git - gldbg.git/blobdiff - source/gldbg.cpp
Fix several problems reported by valgrind
[gldbg.git] / source / gldbg.cpp
index 4bc169fcd0079abb2f99811a87db777266e4e86f..c13d5cc2fa6bbafb1b42c87b38139cf78fd58c10 100644 (file)
@@ -20,8 +20,10 @@ using namespace std;
 GlDbg *GlDbg::instance = 0;
 
 GlDbg::GlDbg(int argc, char **argv):
+       done(false),
        cmd_interp(*this),
        process(vector<string>(argv+1, argv+argc)),
+       sock_fd(-1),
        buf_offset(0),
        flushing(false),
        got_sigchld(false),
@@ -56,7 +58,7 @@ int GlDbg::main()
        printf("Copyright © 2009-2010 Mikkosoft Productions\n");
        printf("Type \"help\" for a list of commands\n");
 
-       while(1)
+       while(!done)
                tick();
 
        return 0;
@@ -179,7 +181,7 @@ void GlDbg::quit(bool force)
 {
        if(!force && process.get_state()!=Process::INACTIVE)
                throw runtime_error("Program is still running");
-       exit(0);
+       done = true;
 }
 
 void GlDbg::tick()
@@ -225,7 +227,7 @@ void GlDbg::tick()
                        free(line);
                }
                else if(pstate==Process::INACTIVE)
-                       exit(0);
+                       done = true;
        }
 }