From 511496a608be4ce2c0189ab0021d05ef2434da89 Mon Sep 17 00:00:00 2001
From: fujuntang <fujuntang@smartai.com>
Date: 星期二, 31 八月 2021 17:32:53 +0800
Subject: [PATCH] Fix the topics parse issue when very long topics are given.

---
 src/bh_api.cpp |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/bh_api.cpp b/src/bh_api.cpp
index b4ba52e..9de5c0b 100644
--- a/src/bh_api.cpp
+++ b/src/bh_api.cpp
@@ -343,7 +343,7 @@
 
         total -= min;
 
-        if ((_input.amount > 1) && (i < (_input.amount - 1))) {
+        if ((total > 1) && (_input.amount > 1) && (i < (_input.amount - 1))) {
           strncpy(topics_buf + count, STR_MAGIC, strlen(STR_MAGIC));
           total -= 1;
           count++;
@@ -775,9 +775,9 @@
         strncpy(topics_buf + count, _input.topics[i], min);
         count += min;
 
-        total -= strlen(_input.topics[i]);
+        total -= min;
 
-        if ((_input.amount > 1) && (i < (_input.amount - 1))) {
+        if ((total > 1) && (_input.amount > 1) && (i < (_input.amount - 1))) {
           strncpy(topics_buf + count, STR_MAGIC, strlen(STR_MAGIC));
           total -= 1;
           count++;
@@ -914,7 +914,7 @@
   int node_arr_len = 0;
 
 #if defined(PRO_DE_SERIALIZE)
-  struct _MsgPublish
+  struct MsgPublish
 	{
 		const char *topic;
 		const char *data;

--
Gitblit v1.8.0