Mercurial > vim
comparison src/channel.c @ 17308:d04de6c49f59 v8.1.1653
patch 8.1.1653: ubsan warns for possibly passing NULL pointer
commit https://github.com/vim/vim/commit/0d07155c8bbaca1a527b79da358438253a60839f
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jul 8 22:04:03 2019 +0200
patch 8.1.1653: ubsan warns for possibly passing NULL pointer
Problem: Ubsan warns for possibly passing NULL pointer.
Solution: Skip code when length is zero. (Dominique Pelle, closes https://github.com/vim/vim/issues/4631)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 08 Jul 2019 22:15:04 +0200 |
parents | fd983b381ec0 |
children | 4a22102fda8f |
comparison
equal
deleted
inserted
replaced
17307:e62f7f537c87 | 17308:d04de6c49f59 |
---|---|
3988 && wq->wq_prev->wq_ga.ga_len + len < 4000) | 3988 && wq->wq_prev->wq_ga.ga_len + len < 4000) |
3989 { | 3989 { |
3990 writeq_T *last = wq->wq_prev; | 3990 writeq_T *last = wq->wq_prev; |
3991 | 3991 |
3992 /* append to the last entry */ | 3992 /* append to the last entry */ |
3993 if (ga_grow(&last->wq_ga, len) == OK) | 3993 if (len > 0 && ga_grow(&last->wq_ga, len) == OK) |
3994 { | 3994 { |
3995 mch_memmove((char *)last->wq_ga.ga_data | 3995 mch_memmove((char *)last->wq_ga.ga_data |
3996 + last->wq_ga.ga_len, | 3996 + last->wq_ga.ga_len, |
3997 buf, len); | 3997 buf, len); |
3998 last->wq_ga.ga_len += len; | 3998 last->wq_ga.ga_len += len; |
4010 wq->wq_next = last; | 4010 wq->wq_next = last; |
4011 else | 4011 else |
4012 wq->wq_prev->wq_next = last; | 4012 wq->wq_prev->wq_next = last; |
4013 wq->wq_prev = last; | 4013 wq->wq_prev = last; |
4014 ga_init2(&last->wq_ga, 1, 1000); | 4014 ga_init2(&last->wq_ga, 1, 1000); |
4015 if (ga_grow(&last->wq_ga, len) == OK) | 4015 if (len > 0 && ga_grow(&last->wq_ga, len) == OK) |
4016 { | 4016 { |
4017 mch_memmove(last->wq_ga.ga_data, buf, len); | 4017 mch_memmove(last->wq_ga.ga_data, buf, len); |
4018 last->wq_ga.ga_len = len; | 4018 last->wq_ga.ga_len = len; |
4019 } | 4019 } |
4020 } | 4020 } |