Skip to contentSkip to conversation

cec-follower/cec-compliance: fix bug in string conversion

PATCH New Johan Fjeldtvedt 1 participant 1 message Aug 19, 2016 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cec-follower/cec-compliance: fix bug in string conversion

In all_dev_types2s: don't try to erase the last two characters in the string if it is empty.

This was fixed in cec-ctl, so the same fix is applied to cec-compliance and cec-follower.

---
 utils/cec-compliance/cec-compliance.cpp | 4 +++-
 utils/cec-follower/cec-follower.cpp     | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
utils/cec-compliance/cec-compliance.cpp +3 -1
index c40d4b1..519c572 100644
@@ -358,7 +358,9 @@ std::string all_dev_types2s(unsigned types)
 		s += "Audio System, ";
 	if (types & CEC_OP_ALL_DEVTYPE_SWITCH)
 		s += "Switch, ";
-	return s.erase(s.length() - 2, 2);
+	if (s.length())
+		return s.erase(s.length() - 2, 2);
+	return s;
 }
 
 std::string rc_src_prof2s(unsigned prof)
utils/cec-follower/cec-follower.cpp +3 -1
index abb06a8..7850ecd 100644
@@ -305,7 +305,9 @@ std::string all_dev_types2s(unsigned types)
 		s += "Audio System, ";
 	if (types & CEC_OP_ALL_DEVTYPE_SWITCH)
 		s += "Switch, ";
-	return s.erase(s.length() - 2, 2);
+	if (s.length())
+		return s.erase(s.length() - 2, 2);
+	return s;
 }
 
 std::string rc_src_prof2s(unsigned prof)
Signature · 1 line
2.7.4