well that code doesnt tell me much because i dont know what list1 and list2 are. im gonna assume that list1 is the first element of the first list and list2 is the first element of the second list. in this case what we want to do is find the last element of the first list and put the second one after it so how about.
while(l->next != NULL) l=l->next;
i cant be more specific unless you show your code and give me a better description of the problem than 'one little bug'
also c++ has a wide range of containers in the stl including std::list you ought to think about using one of these instead unless you are coding a linked list just for understanding.