# HG changeset patch # User Bram Moolenaar # Date 1574630103 -3600 # Node ID c035b4fa4bc5756f6b6ee96c63d5121170c9910d # Parent a05e744cf4f3cd61d14d9170103f1c16b0048f37 patch 8.1.2340: quickfix test fails under valgrind and asan Commit: https://github.com/vim/vim/commit/a106e6cde682bda4ad10ed745acb51975fcb02e0 Author: Bram Moolenaar Date: Sun Nov 24 22:13:58 2019 +0100 patch 8.1.2340: quickfix test fails under valgrind and asan Problem: Quickfix test fails under valgrind and asan. Solution: Make sure long line does not overflow IObuff. (Dominique Pelle, closes #5263) Put back fix for large terminals. (Yegappan Lakshmanan, closes #5264) diff --git a/src/quickfix.c b/src/quickfix.c --- a/src/quickfix.c +++ b/src/quickfix.c @@ -4416,7 +4416,7 @@ qf_buf_add_line(buf_T *buf, linenr_T lnu if (qfp->qf_module != NULL) { - STRCPY(IObuff, qfp->qf_module); + vim_strncpy(IObuff, qfp->qf_module, IOSIZE - 1); len = (int)STRLEN(IObuff); } else if (qfp->qf_fnum != 0 @@ -4424,7 +4424,7 @@ qf_buf_add_line(buf_T *buf, linenr_T lnu && errbuf->b_fname != NULL) { if (qfp->qf_type == 1) // :helpgrep - STRCPY(IObuff, gettail(errbuf->b_fname)); + vim_strncpy(IObuff, gettail(errbuf->b_fname), IOSIZE - 1); else { // shorten the file name if not done already @@ -4435,26 +4435,29 @@ qf_buf_add_line(buf_T *buf, linenr_T lnu mch_dirname(dirname, MAXPATHL); shorten_buf_fname(errbuf, dirname, FALSE); } - STRCPY(IObuff, errbuf->b_fname); + vim_strncpy(IObuff, errbuf->b_fname, IOSIZE - 1); } len = (int)STRLEN(IObuff); } else len = 0; - IObuff[len++] = '|'; + + if (len < IOSIZE - 1) + IObuff[len++] = '|'; if (qfp->qf_lnum > 0) { - sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum); + vim_snprintf((char *)IObuff + len, IOSIZE - len, "%ld", qfp->qf_lnum); len += (int)STRLEN(IObuff + len); if (qfp->qf_col > 0) { - sprintf((char *)IObuff + len, " col %d", qfp->qf_col); + vim_snprintf((char *)IObuff + len, IOSIZE - len, + " col %d", qfp->qf_col); len += (int)STRLEN(IObuff + len); } - sprintf((char *)IObuff + len, "%s", + vim_snprintf((char *)IObuff + len, IOSIZE - len, "%s", (char *)qf_types(qfp->qf_type, qfp->qf_nr)); len += (int)STRLEN(IObuff + len); } @@ -4463,8 +4466,11 @@ qf_buf_add_line(buf_T *buf, linenr_T lnu qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); len += (int)STRLEN(IObuff + len); } - IObuff[len++] = '|'; - IObuff[len++] = ' '; + if (len < IOSIZE - 2) + { + IObuff[len++] = '|'; + IObuff[len++] = ' '; + } // Remove newlines and leading whitespace from the text. // For an unrecognized line keep the indent, the compiler may diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -626,10 +626,15 @@ func s:test_xhelpgrep(cchar) let w3 = win_getid() call assert_true(&buftype == 'help') call assert_true(winnr() == 1) - call win_gotoid(w1) - call assert_equal(w3, win_getid(winnr('k'))) - call win_gotoid(w2) - call assert_equal(w3, win_getid(winnr('k'))) + " See jump_to_help_window() for details + let w2_width = winwidth(w2) + if w2_width != &columns && w2_width < 80 + call assert_equal(['col', [['leaf', w3], + \ ['row', [['leaf', w2], ['leaf', w1]]]]], winlayout()) + else + call assert_equal(['row', [['col', [['leaf', w3], ['leaf', w2]]], + \ ['leaf', w1]]] , winlayout()) + endif new | only set buftype=help diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -738,6 +738,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2340, +/**/ 2339, /**/ 2338,