From 519532da148802b03165c155c03f936670e90fc1 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 19 Apr 2014 13:57:10 +0400 Subject: [PATCH] Fixed undefined behavior --- .../include/uavcan/marshal/char_array_formatter.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libuavcan/include/uavcan/marshal/char_array_formatter.hpp b/libuavcan/include/uavcan/marshal/char_array_formatter.hpp index 76c3948ad0..e805f162a4 100644 --- a/libuavcan/include/uavcan/marshal/char_array_formatter.hpp +++ b/libuavcan/include/uavcan/marshal/char_array_formatter.hpp @@ -85,11 +85,15 @@ public: { while (s && *s) { - if (*s == '%' && *++s != '%') + if (*s == '%') { - writeValue(value); - write(++s, args...); - break; + s += 1; + if (*s != '%') + { + writeValue(value); + write(++s, args...); + break; + } } writeValue(*s++); }