From 35c816d62f38ad0cded0fcec929ae52777cc92f3 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 25 Feb 2021 11:21:34 -0800 Subject: [PATCH] htclow: fix ordering of channels, uninitialized bug in service json parse --- .../include/stratosphere/htclow/impl/htclow_internal_types.hpp | 2 +- .../source/htclow/ctrl/htclow_service_channel_parser.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/htclow/impl/htclow_internal_types.hpp b/libraries/libstratosphere/include/stratosphere/htclow/impl/htclow_internal_types.hpp index bee584a85..7657e31a4 100644 --- a/libraries/libstratosphere/include/stratosphere/htclow/impl/htclow_internal_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/htclow/impl/htclow_internal_types.hpp @@ -43,7 +43,7 @@ namespace ams::htclow::impl { } constexpr ALWAYS_INLINE bool operator<(const ChannelInternalType &lhs, const ChannelInternalType &rhs) { - return lhs.module_id < rhs.module_id || lhs.reserved < rhs.reserved || lhs.channel_id < rhs.channel_id; + return std::tie(lhs.module_id, lhs.reserved, lhs.channel_id) < std::tie(rhs.module_id, rhs.reserved, rhs.channel_id); } constexpr ALWAYS_INLINE bool operator>(const ChannelInternalType &lhs, const ChannelInternalType &rhs) { diff --git a/libraries/libstratosphere/source/htclow/ctrl/htclow_service_channel_parser.cpp b/libraries/libstratosphere/source/htclow/ctrl/htclow_service_channel_parser.cpp index 48d27b132..8a6ab286e 100644 --- a/libraries/libstratosphere/source/htclow/ctrl/htclow_service_channel_parser.cpp +++ b/libraries/libstratosphere/source/htclow/ctrl/htclow_service_channel_parser.cpp @@ -139,7 +139,7 @@ namespace ams::htclow::ctrl { void ParseServiceChannel(s16 *out_version, impl::ChannelInternalType *out_channels, int *out_num_channels, int max_channels, void *str, size_t str_size) { /* Parse the JSON. */ const char *channel_strs[0x20]; - int num_channels; + int num_channels = 0; ParseBody(out_version, channel_strs, std::addressof(num_channels), util::size(channel_strs), str, str_size); /* Parse the channel strings. */