Index: cpukit/libmisc/capture/capture.c
===================================================================
--- cpukit/libmisc/capture/capture.c	(revision f7d27953cb87384601f77d5afc52e337bc39c575)
+++ cpukit/libmisc/capture/capture.c	(revision 3d5bcdedfd078da2ec3a508cbd3a1cd5112335bf)
@@ -314,11 +314,8 @@
 }
 
-void rtems_capture_record_task( rtems_tcb* tcb )
+void rtems_capture_initialize_task( rtems_tcb* tcb )
 {
   rtems_capture_control_t*    control;
-  rtems_capture_task_record_t rec;
-  void*                       ptr;
-
-  rtems_object_get_classic_name( tcb->Object.id, &rec.name );
+  rtems_name                  name;
 
   /*
@@ -327,11 +324,23 @@
    */
 
+  rtems_object_get_classic_name( tcb->Object.id, &name );
+
   if (tcb->Capture.control == NULL) {
     for (control = capture_controls; control != NULL; control = control->next)
       if (rtems_capture_match_name_id (control->name, control->id,
-                                       rec.name, tcb->Object.id))
+                                       name, tcb->Object.id))
         tcb->Capture.control = control;
   }
 
+  tcb->Capture.flags |= RTEMS_CAPTURE_INIT_TASK;
+}
+
+void rtems_capture_record_task( rtems_tcb* tcb )
+{
+  rtems_capture_task_record_t rec;
+  void*                       ptr;
+
+  rtems_object_get_classic_name( tcb->Object.id, &rec.name );
+   
   rec.stack_size = tcb->Start.Initial_stack.size;
   rec.start_priority = _RTEMS_tasks_Priority_from_Core(
@@ -1225,4 +1234,6 @@
   uint32_t                     counted;
   size_t                       ptr_size = 0;
+  size_t                       rel_size = 0;
+  rtems_status_code            ret_val = RTEMS_SUCCESSFUL;
 
   rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
@@ -1238,9 +1249,10 @@
   _Assert(ptr_size >= (count * sizeof(*rec) ));
 
-  ptr_size = 0;
+  rel_size = 0;
   while (counted--)
-  { 
+  {
     rec = (rtems_capture_record_t*) ptr;
-    ptr_size += rec->size;
+    rel_size += rec->size;
+    _Assert( rel_size <= ptr_size );
     ptr += rec->size;
   }
@@ -1248,8 +1260,13 @@
   rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
 
+  if (rel_size > ptr_size ) {
+    ret_val = RTEMS_INVALID_NUMBER;
+    rel_size = ptr_size;
+  }
+
   capture_count -= count;
 
   if (count) 
-    rtems_capture_buffer_free( &capture_records, ptr_size );
+    rtems_capture_buffer_free( &capture_records, rel_size );
 
   capture_flags &= ~RTEMS_CAPTURE_READER_ACTIVE;
@@ -1257,5 +1274,5 @@
   rtems_interrupt_lock_release (&capture_lock, &lock_context);
 
-  return RTEMS_SUCCESSFUL;
+  return ret_val;
 }
 
Index: cpukit/libmisc/capture/capture.h
===================================================================
--- cpukit/libmisc/capture/capture.h	(revision f7d27953cb87384601f77d5afc52e337bc39c575)
+++ cpukit/libmisc/capture/capture.h	(revision 3d5bcdedfd078da2ec3a508cbd3a1cd5112335bf)
@@ -142,5 +142,6 @@
  */
 #define RTEMS_CAPTURE_TRACED      (1U << 0)
-#define RTEMS_CAPTURE_RECORD_TASK (1U << 1)
+#define RTEMS_CAPTURE_INIT_TASK   (1U << 1)
+#define RTEMS_CAPTURE_RECORD_TASK (1U << 2)
 
 /*
@@ -599,4 +600,13 @@
 
 /**
+ * @brief Capture initialize task
+ *
+ * This function initializes capture control in the tcb.
+ *
+ * @param[in] tcb is the task control block for the task
+ */
+void rtems_capture_initialize_task( rtems_tcb* tcb );
+
+/**
  * @brief Capture record task.
  * 
@@ -617,4 +627,16 @@
 static inline bool rtems_capture_task_recorded( rtems_tcb* tcb ) {
   return ( (tcb->Capture.flags & RTEMS_CAPTURE_RECORD_TASK) != 0 );
+}
+
+/**
+ * @brief Capture task initialized
+ *
+ * This function returns true if this task information has been 
+ * initialized.
+ *
+ * @param[in] tcb is the task control block for the task
+ */
+static inline bool rtems_capture_task_initialized( rtems_tcb* tcb ) {
+  return ( (tcb->Capture.flags & RTEMS_CAPTURE_INIT_TASK) != 0 );
 }
 
Index: cpukit/libmisc/capture/capture_user_extension.c
===================================================================
--- cpukit/libmisc/capture/capture_user_extension.c	(revision f7d27953cb87384601f77d5afc52e337bc39c575)
+++ cpukit/libmisc/capture/capture_user_extension.c	(revision 3d5bcdedfd078da2ec3a508cbd3a1cd5112335bf)
@@ -96,4 +96,7 @@
   if (rtems_capture_filter( tcb, events) )
     return;
+  
+  if (!rtems_capture_task_recorded (tcb))
+    rtems_capture_record_task (tcb);
 
   rtems_capture_begin_add_record (tcb, events, size, &ptr);
@@ -142,11 +145,11 @@
    */
 
-  if (!rtems_capture_task_recorded (ct))
-    rtems_capture_record_task (ct);
+  if (!rtems_capture_task_initialized (ct))
+    rtems_capture_initialize_task (ct);
 
   /*
    * Create the new task's capture control block.
    */
-  rtems_capture_record_task (nt);
+  rtems_capture_initialize_task (nt);
 
   if (rtems_capture_trigger (ct, nt, RTEMS_CAPTURE_CREATE))
@@ -171,9 +174,9 @@
    */
 
-  if (!rtems_capture_task_recorded (ct))
-    rtems_capture_record_task (ct);
+  if (!rtems_capture_task_initialized (ct))
+    rtems_capture_initialize_task (ct);
 
   if (st == NULL)
-    rtems_capture_record_task (st);
+    rtems_capture_initialize_task (st);
 
   if (rtems_capture_trigger (ct, st, RTEMS_CAPTURE_START))
@@ -196,9 +199,9 @@
    */
 
-  if (!rtems_capture_task_recorded (ct))
-    rtems_capture_record_task (ct);
-
-  if (!rtems_capture_task_recorded (rt))
-    rtems_capture_record_task (rt);
+  if (!rtems_capture_task_initialized (ct))
+    rtems_capture_initialize_task (ct);
+
+  if (!rtems_capture_task_initialized (rt))
+    rtems_capture_initialize_task (rt);
 
   if (rtems_capture_trigger (ct, rt, RTEMS_CAPTURE_RESTART))
@@ -216,9 +219,9 @@
                            rtems_tcb* dt)
 {
-  if (!rtems_capture_task_recorded (ct))
-    rtems_capture_record_task (ct);
-
-  if (!rtems_capture_task_recorded (dt))
-    rtems_capture_record_task (dt);
+  if (!rtems_capture_task_initialized (ct))
+    rtems_capture_initialize_task (ct);
+
+  if (!rtems_capture_task_initialized (dt))
+    rtems_capture_initialize_task (dt);
 
   if (rtems_capture_trigger (ct, dt, RTEMS_CAPTURE_DELETE))
@@ -240,6 +243,6 @@
    */
 
-  if (!rtems_capture_task_recorded (bt))
-    rtems_capture_record_task (bt);
+  if (!rtems_capture_task_initialized (bt))
+    rtems_capture_initialize_task (bt);
 
   if (rtems_capture_trigger (NULL, bt, RTEMS_CAPTURE_BEGIN))
@@ -259,6 +262,6 @@
    */
 
-  if (!rtems_capture_task_recorded (et))
-    rtems_capture_record_task (et);
+  if (!rtems_capture_task_initialized (et))
+    rtems_capture_initialize_task (et);
 
   if (rtems_capture_trigger (NULL, et, RTEMS_CAPTURE_EXITTED))
@@ -277,6 +280,6 @@
    */
 
-  if (!rtems_capture_task_recorded (tt))
-    rtems_capture_record_task (tt);
+  if (!rtems_capture_task_initialized (tt))
+    rtems_capture_initialize_task (tt);
 
   if (rtems_capture_trigger (NULL, tt, RTEMS_CAPTURE_TERMINATED))
@@ -301,9 +304,9 @@
     rtems_capture_time_t time;
 
-    if (!rtems_capture_task_recorded (ct))
-      rtems_capture_record_task (ct);
-
-    if (!rtems_capture_task_recorded (ht))
-      rtems_capture_record_task (ht);
+    if (!rtems_capture_task_initialized (ct))
+      rtems_capture_initialize_task (ct);
+
+    if (!rtems_capture_task_initialized (ht))
+      rtems_capture_initialize_task (ht);
 
     /*
