s3 perfcount: Fix segfault with smbclient 'echo 3 foo'
authorTim Prouty <tprouty@samba.org>
Sun, 15 Feb 2009 20:36:02 +0000 (12:36 -0800)
committerTim Prouty <tprouty@samba.org>
Mon, 16 Feb 2009 08:29:20 +0000 (00:29 -0800)
source3/modules/perfcount_test.c

index 3221adf15cca85f59a8f1ee0ca119a2c1377405d..b140172af40eef8337009e9fb6fdeb6eb4f8c857 100644 (file)
@@ -227,11 +227,8 @@ static void perfcount_test_add(struct smb_perfcount_data *pcd)
                (struct perfcount_test_context *)pcd->context;
        struct perfcount_test_counter *ctr;
 
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_add - uninitialized "
-                       "perfcount context - %p\n", pcd));
+        if (pcd->context == NULL)
                 return;
-       }
 
        ctr = SMB_MALLOC_P(struct perfcount_test_counter);
        if (!ctr) {
@@ -247,11 +244,8 @@ static void perfcount_test_set_op(struct smb_perfcount_data *pcd, int op)
        struct perfcount_test_context *ctxt =
                (struct perfcount_test_context *)pcd->context;
 
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_set_op - uninitialized "
-                       "perfcount context - %p\n", pcd));
+        if (pcd->context == NULL)
                 return;
-       }
 
        ctxt->ops->op = op;
 }
@@ -261,11 +255,8 @@ static void perfcount_test_set_subop(struct smb_perfcount_data *pcd, int sub_op)
        struct perfcount_test_context *ctxt =
                (struct perfcount_test_context *)pcd->context;
 
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_set_sub_op - uninitialized "
-                       "perfcount context - %p\n", pcd));
+        if (pcd->context == NULL)
                 return;
-       }
 
        ctxt->ops->sub_op = sub_op;
 }
@@ -274,11 +265,9 @@ static void perfcount_test_set_ioctl(struct smb_perfcount_data *pcd, int io_ctl)
 {
        struct perfcount_test_context *ctxt =
                (struct perfcount_test_context *)pcd->context;
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_set_ioctl - uninitialized "
-                       "perfcount context - %p\n", pcd));
+        if (pcd->context == NULL)
                 return;
-       }
+
        ctxt->ops->ioctl = io_ctl;
 }
 
@@ -287,11 +276,9 @@ static void perfcount_test_set_msglen_in(struct smb_perfcount_data *pcd,
 {
        struct perfcount_test_context *ctxt =
                (struct perfcount_test_context *)pcd->context;
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_set_msglen_in - "
-                       "uninitialized perfcount context - %p\n", pcd));
+        if (pcd->context == NULL)
                 return;
-       }
+
        ctxt->ops->bytes_in = bytes_in;
 }
 
@@ -301,11 +288,8 @@ static void perfcount_test_set_msglen_out(struct smb_perfcount_data *pcd,
        struct perfcount_test_context *ctxt =
                (struct perfcount_test_context *)pcd->context;
 
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_set_msglen_out - uninitialized "
-                       "perfcount context - %p\n", pcd));
+        if (pcd->context == NULL)
                 return;
-       }
 
        ctxt->ops->bytes_out = bytes_out;
 }
@@ -318,11 +302,7 @@ static void perfcount_test_defer_op(struct smb_perfcount_data *pcd,
                                    struct smb_perfcount_data *def_pcd)
 {
        /* we don't do anything special to deferred ops */
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_set_msglen_out - uninitialized "
-                       "perfcount context - %p\n", pcd));
-                return;
-       }
+       return;
 }
 
 static void perfcount_test_set_client(struct smb_perfcount_data *pcd,
@@ -337,15 +317,13 @@ static void perfcount_test_end(struct smb_perfcount_data *pcd)
 {
        struct perfcount_test_context *ctxt =
                (struct perfcount_test_context *)pcd->context;
-        if (pcd->context == NULL) {
-               DEBUG(0,("perfcount_test_end - uninitialized "
-                       "perfcount context - %p\n", pcd));
+        if (pcd->context == NULL)
                 return;
-       }
 
        /* @bug - we don't store outbytes right for chained cmds */
        perfcount_test_add_counters(ctxt);
        perfcount_test_dump_counters();
+       pcd->context = NULL;
        SAFE_FREE(ctxt);
 }