s3:libsmb fix a potential crash
authorChristian Ambach <ambi@samba.org>
Sat, 15 Sep 2012 22:15:21 +0000 (00:15 +0200)
committerChristian Ambach <ambi@samba.org>
Sun, 16 Sep 2012 20:31:38 +0000 (22:31 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Christian Ambach <ambi@samba.org>
Autobuild-Date(master): Sun Sep 16 22:31:38 CEST 2012 on sn-devel-104

source3/libsmb/pylibsmb.c

index d8e64b35682c6fd2e6a96e46ffb3f84e310573ff..611d07abae27e4d9b7d50acbf44966d59ed87dc2 100644 (file)
@@ -166,7 +166,7 @@ static int py_cli_thread_destructor(struct py_cli_thread *t)
 
 static bool py_cli_state_setup_ev(struct py_cli_state *self)
 {
-       struct py_cli_thread *t;
+       struct py_cli_thread *t = NULL;
        int ret;
 
        self->ev = tevent_context_init_byname(NULL, "poll_mt");
@@ -202,15 +202,18 @@ static bool py_cli_state_setup_ev(struct py_cli_state *self)
        return true;
 
 fail:
-       TALLOC_FREE(t->shutdown_fde);
+       if (t != NULL) {
+               TALLOC_FREE(t->shutdown_fde);
 
-       if (t->shutdown_pipe[0] != -1) {
-               close(t->shutdown_pipe[0]);
-               t->shutdown_pipe[0] = -1;
-       }
-       if (t->shutdown_pipe[1] != -1) {
-               close(t->shutdown_pipe[1]);
-               t->shutdown_pipe[1] = -1;
+               if (t->shutdown_pipe[0] != -1) {
+                       close(t->shutdown_pipe[0]);
+                       t->shutdown_pipe[0] = -1;
+               }
+               if (t->shutdown_pipe[1] != -1) {
+                       close(t->shutdown_pipe[1]);
+                       t->shutdown_pipe[1] = -1;
+               }
+               TALLOC_FREE(t);
        }
 
        TALLOC_FREE(self->thread_state);