From c72238fb7fc6eb081c2a0bc95fff369c760343f4 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Tue, 25 Nov 2008 14:58:48 +0000 Subject: [PATCH] libt2n: (tomj) fix uninitialized variable "result_type" in result_container --- src/container.cpp | 6 ++++++ src/container.hxx | 27 ++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/container.cpp b/src/container.cpp index 47d0e49..0401af8 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -40,6 +40,9 @@ result_container::~result_container() delete res; if (ex) delete ex; + + res = NULL; + ex = NULL; } /** @brief returns the result or throw the carried exception. @@ -49,6 +52,7 @@ result* result_container::get_result(void) { if (result_type==exception) ex->do_throw(); + return res; } @@ -57,6 +61,8 @@ command_container::~command_container() { if (cmd) delete cmd; + + cmd = NULL; } } // namespace libt2n diff --git a/src/container.hxx b/src/container.hxx index 478c464..020194b 100644 --- a/src/container.hxx +++ b/src/container.hxx @@ -49,17 +49,31 @@ class result_container public: result_container() - { res=0; ex=0; } + : res(NULL) + , ex(NULL) + , result_type(regular) + { + } result_container(result *_res) - { set_result(_res); } + : res(_res) + , ex(NULL) + , result_type(regular) + { + } + result_container(t2n_exception *_ex) - { set_exception(_ex); } + : res(NULL) + , ex(_ex) + , result_type(exception) + { + } ~result_container(); void set_result(result *_res) { res=_res; ex=0; result_type=regular; } + void set_exception(t2n_exception *_ex) { res=0; ex=_ex; result_type=exception; } @@ -84,9 +98,12 @@ class command_container public: command_container() - { cmd=0; } + : cmd(NULL) + {} + command_container(command *_cmd) - { cmd=_cmd; } + : cmd(_cmd) + {} ~command_container(); -- 1.7.1