added free() statements for test cases str3, str4