From faa000edcb97482c4f8adc3f436344584ceca326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Wed, 12 Nov 2014 22:49:29 +0100 Subject: [PATCH] Fix warnings: spell.c: spell_move_to(): Null arg: FP. Problem : Argument with 'nonnull' attribute passed null @ 2118. Diagnostic : False positive. Rationale : Error happens when `if (buflen < len + MAXWLEN + 2) {` is not entered on the first iteration, which cannot happen because buflen is 0 on the first iteration, so the condition should always hold. Resolution : Assert existence of buffer with appropiate length after conditional (which prevents previous error path). --- src/nvim/spell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 38d52a7f53..d52961b799 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -284,6 +284,7 @@ // stored as an offset to the previous number in as // few bytes as possible, see offset2bytes()) +#include #include #include #include @@ -2096,6 +2097,7 @@ spell_move_to ( buflen = len + MAXWLEN + 2; buf = xmalloc(buflen); } + assert(buf && buflen >= len + MAXWLEN + 2); // In first line check first word for Capital. if (lnum == 1)