Clarify the code that caused many sleepless engineers 88/232288/6
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Wed, 29 Apr 2020 16:29:53 +0000 (18:29 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Fri, 26 Jun 2020 15:36:20 +0000 (17:36 +0200)
We have to stop this madness.

Change-Id: I7407efe46ac02c0c2427966eb4bd52db180522fc

src/debug.c

index e23214b..1e6035d 100644 (file)
@@ -104,13 +104,16 @@ void error_dump(const char *file, int line, const char *function, int code)
                }
        }
 
+       /* In case the while broke early due to the BUF_SIZE, write
+        * ellipsis and clear remaining errors that might have not been
+        * read by ERR_get_error() */
        if (written >= BUF_SIZE - 1) {
                strncpy(buf + BUF_SIZE - ELLIPSIS_SIZE, ELLIPSIS, ELLIPSIS_SIZE);
                written = BUF_SIZE - 1;
                ERR_clear_error();
        }
-       buf[written] = '\0';
 
+       buf[written] = '\0';
        (*error_cb)(buf);
 }