Handle messages that are empty (or which appear empty to MSG4 because they consist...
authorArt Cancro <ajc@citadel.org>
Sat, 26 Feb 2022 20:13:14 +0000 (15:13 -0500)
committerArt Cancro <ajc@citadel.org>
Sat, 26 Feb 2022 20:13:14 +0000 (15:13 -0500)
webcit-ng/ctdlclient.c
webcit-ng/forum_view.c

index a861e2af7ff2cd2445edb50e7cafa4d7f38b48e9..44daa3b55d1e282695f3462cb2d626f15a695152 100644 (file)
@@ -77,7 +77,7 @@ StrBuf *ctdl_readtextmsg(struct ctdlsession *ctdl) {
                return NULL;
        }
 
-       while ((ctdl_readline(ctdl, buf, sizeof(buf)) >= 0) && (strcmp(buf, "000"))) {
+       while (ctdl_readline(ctdl, buf, sizeof(buf)), strcmp(buf, "000")) {
                StrBufAppendPrintf(sj, "%s\n", buf);
        }
 
index 846c417b5e32bfc4ecaa548b3e335f103fe0f536..80320ec84b04ead23e95f6f36f416e4c1de8ab0a 100644 (file)
@@ -93,7 +93,12 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c,
                                striplt(content_type);
                        }
                }
-               raw_msg = ctdl_readtextmsg(c);
+               if (!strcmp(buf, "000")) {              // if we have an empty message, don't try to read further
+                       raw_msg = NULL;
+               }
+               else {
+                       raw_msg = ctdl_readtextmsg(c);
+               }
        }
        else {
                raw_msg = NULL;