From 232c35b89ecbde61c7d0ed818592ae8520a78f1e Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Thu, 4 Jun 2015 20:06:49 -0700 Subject: [PATCH] Use the right sizes. Nice catch DrChat. --- src/xenia/kernel/objects/xthread.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 426b036c0..1fbbff29c 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -186,21 +186,23 @@ X_STATUS XThread::Create() { } // Allocate both the slots and the extended data. - uint32_t tls_size = tls_slots * 4 + tls_extended_size; - tls_address_ = memory()->SystemHeapAlloc(tls_size); + uint32_t tls_slot_size = tls_slots * 4; + uint32_t tls_total_size = tls_slot_size + tls_extended_size; + tls_address_ = memory()->SystemHeapAlloc(tls_total_size); if (!tls_address_) { XELOGW("Unable to allocate thread local storage block"); return X_STATUS_NO_MEMORY; } // Zero all of TLS. - memory()->Fill(tls_address_, tls_size, 0); + memory()->Fill(tls_address_, tls_total_size, 0); if (tls_extended_size) { // If game has extended data, copy in the default values. const xe_xex2_header_t* header = module->xex_header(); assert_not_zero(header->tls_info.raw_data_address); // TODO(benvanik): verify location relative to slots. - memory()->Copy(tls_address_ + tls_size, header->tls_info.raw_data_address, + memory()->Copy(tls_address_ + tls_slot_size, + header->tls_info.raw_data_address, header->tls_info.raw_data_size); }