Hi guys,

I am implementing a singly linked list. The thing is whenever my str_temp goes above 12-15 elements, i get this error

malloc: *** error for object 0x1099008b8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Run Command: line 1: 7322 Abort trap: 6 ./"$2"

The error is happening in AppendNode method. Can you please tell me where I might be going wrong.
Code snippet is given below. Please let me know if you need more info.

class node{
    int data;
    class node* next;

class IO{
    int numReq;
    class node *head;
    class node *tail;
    void makeList(int*);
    void makeSorted(int*);    
    void printList();
    void SortedInsert(class node*&,int); 
    void InsertSort();
    void AppendNode(int);

void IO::makeList(int str_temp[]){
    int i;
    cout<<"NUMREQ "<<numReq<<endl;
    for (i=0;i<numReq;i++) {

void IO::AppendNode(int num) {
   class node* current = head;
   class node* newNode;
   newNode = new node();
   newNode->data = num;
   newNode->next = NULL;

   // special case for length 0
   if (current == NULL) {
      head = newNode;
   else {
      // Locate the last node
      while (current->next != NULL) {
         current = current->next;
      current->next = newNode;


can you tell us the value of:
that gives you the error

str_temp = 89 92 201 128 10 1 2 3 4 5 6 6 7 7 23
numReq = 15

i didnot get that error so please
check that head is set to NULL before call the build
if not solved please upload the ehole project cause there might be other problem

I am initializing it to null.

IO::IO(int num):numReq(num),head(NULL),tail(NULL){

can you upload full simple sample that generates the error cause i canot find it?