]> granicus.if.org Git - vim/commitdiff
Fixes for coverity warnings.
authorBram Moolenaar <Bram@vim.org>
Sat, 31 Jul 2010 14:44:19 +0000 (16:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 31 Jul 2010 14:44:19 +0000 (16:44 +0200)
runtime/doc/diff.txt
runtime/doc/todo.txt
src/diff.c
src/ex_getln.c
src/hardcopy.c
src/misc2.c
src/netbeans.c
src/normal.c
src/option.c
src/spell.c
src/ui.c

index 1b5c2a1392e782e38e674ef6ecfce4d7df3f6960..c94bf69a3a7ea92c9b0114e4b15c05eb0ea80cf5 100644 (file)
@@ -1,4 +1,4 @@
-*diff.txt*      For Vim version 7.3c.  Last change: 2009 Sep 15
+*diff.txt*      For Vim version 7.3c.  Last change: 2010 Jul 31
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -57,6 +57,7 @@ In each of the edited files these options are set:
 
        'diff'          on
        'scrollbind'    on
+       'cursorbind'    on
        'scrollopt'     includes "hor"
        'wrap'          off
        'foldmethod'    "diff"
@@ -133,6 +134,7 @@ the old values are not remembered.
 
        'diff'          off
        'scrollbind'    off
+       'cursorbind'    off
        'scrollopt'     without "hor"
        'wrap'          on
        'foldmethod'    "manual"
index d50f65add4796c3789d2aa32c1d73eb2742d717c..e887fd35fce777f33d187e688dca4d2c3af95d9c 100644 (file)
@@ -30,8 +30,6 @@ be worked on, but only if you sponsor Vim development.  See |sponsor|.
                                                        *known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-After ":diffoff" scroll binding doesn't stop completely.
-
 Windows 7: "Open with..." menu starts Vim without a file.
 Need to use other registry methods in if_ole.cpp?
 
@@ -39,9 +37,6 @@ Windows 7: installing Vim again doesn't find the previously installed Vim.
 
 Move more common code from if_python.c and if_python3.c to if_py_both.h
 
-Add filetype completion to user commands. (Christian Brabandt, 2010 Jul 26)
-But call it "filetype" instead of "syntax"?
-
 Uninspected issues on http://scan.coverity.com/rung2.html
 
 Before release 7.3:
index e733ccd45c011d35523a0d02a851d5a31a155fc8..9b6d2791f0c60bef2300d7abca3a4c6e7ee15143 100644 (file)
@@ -1177,6 +1177,9 @@ ex_diffoff(eap)
        {
            /* Set 'diff', 'scrollbind' off and 'wrap' on. */
            wp->w_p_diff = FALSE;
+#ifdef FEAT_CURSORBIND
+           wp->w_p_crb = FALSE;
+#endif
            wp->w_p_scb = FALSE;
            wp->w_p_wrap = TRUE;
 #ifdef FEAT_FOLDING
@@ -2360,7 +2363,7 @@ ex_diffgetput(eap)
     }
 
     /* restore curwin/curbuf and a few other things */
-    if (idx_other == idx_to)
+    if (eap->cmdidx != CMD_diffget)
     {
        /* Syncing undo only works for the current buffer, but we change
         * another buffer.  Sync undo if the command was typed.  This isn't
index b292f639162ca326d3635d085cb951f1035a34a5..790d5315a0da68ed9f9e28569ff4c03e6e06d67d 100644 (file)
@@ -3780,7 +3780,7 @@ vim_strsave_fnameescape(fname, shell)
 
     /* '>' and '+' are special at the start of some commands, e.g. ":edit" and
      * ":write".  "cd -" has a special meaning. */
-    if (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL))
+    if (p != NULL && (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL)))
        escape_fname(&p);
 
     return p;
index 744a2a2f19e02872f787bb752b4c79fd6e33bf9c..0747dc9d3efe0b46daf79bbc5a5a968792513bc5 100644 (file)
@@ -1943,6 +1943,7 @@ prt_open_resource(resource)
        fclose(fd_resource);
        return FALSE;
     }
+    fclose(fd_resource);
 
     prt_resfile.line_end = -1;
     prt_resfile.line_start = 0;
@@ -1956,7 +1957,6 @@ prt_open_resource(resource)
     {
        EMSG2(_("E618: file \"%s\" is not a PostScript resource file"),
                resource->filename);
-       fclose(fd_resource);
        return FALSE;
     }
 
@@ -1974,7 +1974,6 @@ prt_open_resource(resource)
     {
        EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
                resource->filename);
-       fclose(fd_resource);
        return FALSE;
     }
     offset += (int)STRLEN(PRT_RESOURCE_RESOURCE);
@@ -1993,7 +1992,6 @@ prt_open_resource(resource)
     {
        EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
                resource->filename);
-       fclose(fd_resource);
        return FALSE;
     }
 
@@ -2036,12 +2034,9 @@ prt_open_resource(resource)
     {
        EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
                resource->filename);
-       fclose(fd_resource);
        return FALSE;
     }
 
-    fclose(fd_resource);
-
     return TRUE;
 }
 
index 6b9ffe151cfd6d212df572c4da0e78a01cb7ca90..96813a484151b95d6a2090a39d82bfae267f256a 100644 (file)
@@ -4533,8 +4533,9 @@ vim_findfile_init(path, filename, stopdirs, level, free_visited, find_what,
         * This is needed if the parameter path is fully qualified.
         */
        search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path);
-       if (search_ctx->ffsc_start_dir)
-           search_ctx->ffsc_fix_path[0] = NUL;
+       if (search_ctx->ffsc_start_dir == NULL)
+           goto error_return;
+       search_ctx->ffsc_fix_path[0] = NUL;
     }
 
     /* create an absolute path */
index 00c7ce20b998114e14c6ed8361ab263b4eb236d3..68914eb12e3f13416afa900e91128f5ebd759627 100644 (file)
@@ -3682,17 +3682,18 @@ addsigntype(
        if (buf->signmaplen == 0) /* first allocation */
        {
            buf->signmaplen = 5;
-           buf->signmap = (int *)alloc_clear(buf->signmaplen * sizeof(int *));
+           buf->signmap = (int *)alloc_clear(buf->signmaplen * sizeof(int));
        }
        else    /* grow it */
        {
            int incr;
            int oldlen = buf->signmaplen;
+
            buf->signmaplen *= 2;
            incr = buf->signmaplen - oldlen;
            buf->signmap = (int *)vim_realloc(buf->signmap,
-                                              buf->signmaplen*sizeof(int *));
-           vim_memset(buf->signmap + oldlen, 0, incr * sizeof(int *));
+                                              buf->signmaplen * sizeof(int));
+           vim_memset(buf->signmap + oldlen, 0, incr * sizeof(int));
        }
     }
 
index e17aec3154b0dbe4db4a3032aefd73cb727cc092..b76e40d1de0e2b3d1bdf06d41419ad0efb287a99 100644 (file)
@@ -6358,7 +6358,7 @@ nv_csearch(cap)
 nv_brackets(cap)
     cmdarg_T   *cap;
 {
-    pos_T      new_pos;
+    pos_T      new_pos = INIT_POS_T(0, 0, 0);
     pos_T      prev_pos;
     pos_T      *pos = NULL;        /* init for GCC */
     pos_T      old_pos;            /* cursor position before command */
@@ -6436,7 +6436,6 @@ nv_brackets(cap)
     {
        if (cap->nchar == '*')
            cap->nchar = '/';
-       new_pos.lnum = 0;
        prev_pos.lnum = 0;
        if (cap->nchar == 'm' || cap->nchar == 'M')
        {
index 2c5e88bfbdcbf16fa7b01fd40effcf92e46d92ab..06e569ca45d9ec0f15f7ff509444065fa70004b4 100644 (file)
@@ -3212,6 +3212,8 @@ set_init_1()
                    options[opt_idx].def_val[VI_DEFAULT] = buf;
                    options[opt_idx].flags |= P_DEF_ALLOCED;
                }
+               else
+                   vim_free(buf); /* cannot happen */
            }
            if (mustfree)
                vim_free(cdpath);
@@ -4262,6 +4264,7 @@ do_set(arg, opt_flags)
                 * 'foldmethod' becomes "marker" instead of "diff" and that
                 * "wrap" gets set. */
                if (curwin->w_p_diff
+                       && opt_idx >= 0  /* shut up coverity warning */
                        && (options[opt_idx].indir == PV_FDM
                            || options[opt_idx].indir == PV_WRAP))
                    goto skip;
index 6d4d47ea213b717fe80f0f7a8dda8aaf8bd82172..30510ad27176cc23388f8965852dc4607642f2a3 100644 (file)
@@ -9439,7 +9439,8 @@ spell_add_word(word, len, bad, idx, undo)
                    fseek(fd, fpos_next, SEEK_SET);
                }
            }
-           fclose(fd);
+           if (fd != NULL)
+               fclose(fd);
        }
     }
 
index fbdc325355b6937e1b8adec88d411612cda0c3d0..a05490c67c56ce5676b9d646190a91b7d4c13e30 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -3100,6 +3100,9 @@ get_fpos_of_mouse(mpos)
 
     if (mpos->col > 0)
        --mpos->col;
+#ifdef FEAT_VIRTUALEDIT
+    mpos->coladd = 0;
+#endif
     return IN_BUFFER;
 }