To: vim_dev@googlegroups.com Subject: Patch 8.2.0387 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0387 Problem: Error for possible NULL argument to qsort(). Solution: Don't call qsort() when there is nothing to sort. (Dominique Pelle, closes #5780) Files: src/spellsuggest.c *** ../vim-8.2.0386/src/spellsuggest.c 2019-12-25 14:13:00.241985456 +0100 --- src/spellsuggest.c 2020-03-15 18:13:18.943277934 +0100 *************** *** 3719,3735 **** suggest_T *stp = &SUG(*gap, 0); int i; ! // Sort the list. ! qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), sug_compare); ! ! // Truncate the list to the number of suggestions that will be displayed. ! if (gap->ga_len > keep) { ! for (i = keep; i < gap->ga_len; ++i) ! vim_free(stp[i].st_word); ! gap->ga_len = keep; ! if (keep >= 1) ! return stp[keep - 1].st_score; } return maxscore; } --- 3719,3740 ---- suggest_T *stp = &SUG(*gap, 0); int i; ! if (gap->ga_len > 0) { ! // Sort the list. ! qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), ! sug_compare); ! ! // Truncate the list to the number of suggestions that will be ! // displayed. ! if (gap->ga_len > keep) ! { ! for (i = keep; i < gap->ga_len; ++i) ! vim_free(stp[i].st_word); ! gap->ga_len = keep; ! if (keep >= 1) ! return stp[keep - 1].st_score; ! } } return maxscore; } *** ../vim-8.2.0386/src/version.c 2020-03-15 16:51:36.934946237 +0100 --- src/version.c 2020-03-15 18:14:17.771043831 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 387, /**/ -- hundred-and-one symptoms of being an internet addict: 269. You wonder how you can make your dustbin produce Sesame Street's Oscar's the Garbage Monster song when you empty it. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///