summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChloe Marcec <dmarcecguzman@gmail.com>2021-01-23 08:24:57 +0100
committerChloe Marcec <dmarcecguzman@gmail.com>2021-01-23 08:24:57 +0100
commitdf4210032060ac271bb6c909d489ff094e16b7b9 (patch)
treeb8019bec3e4b4a7b86ffdb362635f5b2535a1984
parentMark DestinationToString as static (diff)
downloadyuzu-df4210032060ac271bb6c909d489ff094e16b7b9.tar
yuzu-df4210032060ac271bb6c909d489ff094e16b7b9.tar.gz
yuzu-df4210032060ac271bb6c909d489ff094e16b7b9.tar.bz2
yuzu-df4210032060ac271bb6c909d489ff094e16b7b9.tar.lz
yuzu-df4210032060ac271bb6c909d489ff094e16b7b9.tar.xz
yuzu-df4210032060ac271bb6c909d489ff094e16b7b9.tar.zst
yuzu-df4210032060ac271bb6c909d489ff094e16b7b9.zip
-rw-r--r--src/core/hle/service/lm/lm.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 4e0b4ea09..90e9e691a 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -162,9 +162,11 @@ private:
if (length == 0) {
return std::nullopt;
}
- std::string output(length, '\0');
- std::memcpy(output.data(), data.data() + offset, length);
- offset += length;
+ const auto length_to_read = std::min(length, data.size() - offset);
+
+ std::string output(length_to_read, '\0');
+ std::memcpy(output.data(), data.data() + offset, length_to_read);
+ offset += length_to_read;
return output;
}