aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2015-04-26 11:40:29 +0200
committerEliseo Martínez <eliseomarmol@gmail.com>2015-04-27 15:55:03 +0200
commit8ee09a3bd27a61740c366d8b4373e1f19191840c (patch)
treeecb9dc561b02cf49748867b10030e5cf04cc90d3 /src/nvim/ex_getln.c
parentd9441444afa3e99c8116ad01b11614886aa53524 (diff)
downloadrneovim-8ee09a3bd27a61740c366d8b4373e1f19191840c.tar.gz
rneovim-8ee09a3bd27a61740c366d8b4373e1f19191840c.tar.bz2
rneovim-8ee09a3bd27a61740c366d8b4373e1f19191840c.zip
Fix warnings: ex_getln.c: init_history(): Nonnull attr passed null: HI.
Problem : Argument with 'nonnull' attribute passed null @ 4227. Diagnostic : Harmless issue. Rationale : It's true we're calling memset with NULL pointer, but it's also true we're doing it with zero size. We just thought that would work and do nothing (it was a way of avoiding to add a guard). It doesn't work, though, as memset requires nonnull arguments. Resolution : Add guard to avoid null argument.
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 65d6dd676f..c7cb0c7294 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -4239,7 +4239,9 @@ void init_history(void)
// clear remaining space, if any
int l3 = j < 0 ? 0 : MIN(newlen, oldlen); // number of copied entries
- memset(temp + l3, 0, (size_t)(newlen - l3) * sizeof(*temp));
+ if (newlen) {
+ memset(temp + l3, 0, (size_t)(newlen - l3) * sizeof(*temp));
+ }
hisidx[type] = l3 - 1;
xfree(history[type]);