diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 8a59fd344ed09668e5e873d2da96378720854cc6..3c029f5a053f89508c169abc6bd0d70bc96422c2 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -198,6 +198,9 @@ int gdb_thread_packet(struct connection *connection, char *packet, int packet_si
 				tmp_str_ptr += sprintf( tmp_str_ptr, " : %s", detail->extra_info_str );
 			}
 
+			assert(strlen(tmp_str) ==
+				(size_t) (tmp_str_ptr - tmp_str));
+
 			char * hex_str = (char*) malloc( strlen(tmp_str)*2 +1 );
 			str_to_hex( hex_str, tmp_str );