diff options
| author | 2020-09-17 10:54:09 -0400 | |
|---|---|---|
| committer | 2020-09-17 10:54:12 -0400 | |
| commit | 057aa6275d4bfcdf043d0181d5284ca2023faaf2 (patch) | |
| tree | 916ce4df44cb507e680c9949c125c35c59dddb8c /src | |
| parent | service/sm: Eliminate dependency on the global system instance (diff) | |
| download | yuzu-057aa6275d4bfcdf043d0181d5284ca2023faaf2.tar.gz yuzu-057aa6275d4bfcdf043d0181d5284ca2023faaf2.tar.xz yuzu-057aa6275d4bfcdf043d0181d5284ca2023faaf2.zip | |
service/sm: Slightly more efficient string name validation
We can check the end of the string first for null-termination, rather
than the beginning of the string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/sm/sm.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 2aedc93ea..9c1da361b 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp | |||
| @@ -27,11 +27,11 @@ void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { | |||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | static ResultCode ValidateServiceName(const std::string& name) { | 29 | static ResultCode ValidateServiceName(const std::string& name) { |
| 30 | if (name.size() <= 0 || name.size() > 8) { | 30 | if (name.empty() || name.size() > 8) { |
| 31 | LOG_ERROR(Service_SM, "Invalid service name! service={}", name); | 31 | LOG_ERROR(Service_SM, "Invalid service name! service={}", name); |
| 32 | return ERR_INVALID_NAME; | 32 | return ERR_INVALID_NAME; |
| 33 | } | 33 | } |
| 34 | if (name.find('\0') != std::string::npos) { | 34 | if (name.rfind('\0') != std::string::npos) { |
| 35 | LOG_ERROR(Service_SM, "A non null terminated service was passed"); | 35 | LOG_ERROR(Service_SM, "A non null terminated service was passed"); |
| 36 | return ERR_INVALID_NAME; | 36 | return ERR_INVALID_NAME; |
| 37 | } | 37 | } |