if (VG_(threads)[i].status == VgTs_Empty) {
VG_(threads)[i].status = VgTs_Init;
VG_(threads)[i].exitreason = VgSrc_None;
- VG_(threads)[i].thread_name = NULL;
+ if (VG_(threads)[i].thread_name)
+ VG_(arena_free)(VG_AR_CORE, VG_(threads)[i].thread_name);
+ VG_(threads)[i].thread_name = NULL;
return i;
}
}
const HChar* new_name = (const HChar*) ARG2;
if (new_name) { // Paranoia
ThreadState* tst = VG_(get_ThreadState)(tid);
+ SizeT new_len = VG_(strlen)(new_name);
/* Don't bother reusing the memory. This is a rare event. */
tst->thread_name =
- VG_(arena_strdup)(VG_AR_CORE, "syswrap.prctl", new_name);
+ VG_(arena_realloc)(VG_AR_CORE, "syswrap.prctl",
+ tst->thread_name, new_len + 1);
+ VG_(strcpy)(tst->thread_name, new_name);
}
}
break;