Dominique wrote:
> Bram Moolenaar <b...@moolenaar.net> wrote: > > > Patch 8.1.1653 > > Problem: Ubsan warns for possibly passing NULL pointer. > > Solution: Skip code when length is zero. (Dominique Pelle, closes #4631) > > Files: src/channel.c > > > > > > *** ../vim-8.1.1652/src/channel.c 2019-06-28 22:06:41.110072146 +0200 > > --- src/channel.c 2019-07-08 22:01:10.759502396 +0200 > > *************** > > *** 3990,3996 **** > > writeq_T *last = wq->wq_prev; > > > > /* append to the last entry */ > > ! if (ga_grow(&last->wq_ga, len) == OK) > > { > > mch_memmove((char *)last->wq_ga.ga_data > > + > > last->wq_ga.ga_len, > > --- 3990,3996 ---- > > writeq_T *last = wq->wq_prev; > > > > /* append to the last entry */ > > ! if (len > 0 && ga_grow(&last->wq_ga, len) == OK) > > { > > mch_memmove((char *)last->wq_ga.ga_data > > + > > last->wq_ga.ga_len, > > *************** > > *** 4012,4018 **** > > wq->wq_prev->wq_next = last; > > wq->wq_prev = last; > > ga_init2(&last->wq_ga, 1, 1000); > > ! if (ga_grow(&last->wq_ga, len) == OK) > > { > > mch_memmove(last->wq_ga.ga_data, buf, len); > > last->wq_ga.ga_len = len; > > --- 4012,4018 ---- > > wq->wq_prev->wq_next = last; > > wq->wq_prev = last; > > ga_init2(&last->wq_ga, 1, 1000); > > ! if (len > 0 && ga_grow(&last->wq_ga, len) == OK) > > { > > mch_memmove(last->wq_ga.ga_data, buf, len); > > last->wq_ga.ga_len = len; > > The 2nd chunk of the diff does not seem correct and > is different from how I fixed it in my original PR. > > If len is 0, old code used to set last->wq_ga.ga_len to 0 but now > that this is skipped. Only the mch_memmove(...) called should have > been skipped. That should be OK, because ga_init2() sets the length to zero. But perhaps Ubsan doesn't handle this logic? -- Courtroom Quote #19: Q: Doctor, how many autopsies have you performed on dead people? A: All my autopsies have been performed on dead people. /// Bram Moolenaar -- b...@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 /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/201907082130.x68LUdIR003013%40masaka.moolenaar.net. For more options, visit https://groups.google.com/d/optout.