baton->dyld = info.all_image_info_addr;
baton->pid = getpid();
+ memset(baton->error, 0, sizeof(baton->error));
memcpy(baton->library, library, length);
mach_vm_size_t size(depth + Stack_);
mach_vm_size_t error(sizeof(baton->error));
_krncall(mach_vm_read_overwrite(task, data + offsetof(Baton, error), sizeof(baton->error), reinterpret_cast<mach_vm_address_t>(&baton->error), &error));
_assert(error == sizeof(baton->error));
- if (baton->error[0] != '\0')
+
+ if (baton->error[0] != '\0') {
+ baton->error[sizeof(baton->error) - 1] = '\0';
CYThrow("%s", baton->error);
+ }
_krncall(mach_vm_deallocate(task, code, trampoline->size_));
_krncall(mach_vm_deallocate(task, stack, size));