Merge branch 'jk/janitorial-fixes'
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Mar 2014 21:24:37 +0000 (14:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Mar 2014 21:24:37 +0000 (14:24 -0700)
* jk/janitorial-fixes:
open_istream(): do not dereference NULL in the error case
builtin/mv: don't use memory after free
utf8: use correct type for values in interval table
utf8: fix iconv error detection
notes-utils: handle boolean notes.rewritemode correctly

builtin/mv.c
notes-utils.c
streaming.c
utf8.c
index 21c46d1636e6e87dd9eaaca60ac08ebbbc4efec3..7e26eb5229a0c8a526314cecb9860c3dfb0fed00 100644 (file)
@@ -162,7 +162,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                        if (strncmp(path, src_w_slash, len_w_slash))
                                                break;
                                }
-                               free((char *)src_w_slash);
+                               if (src_w_slash != src)
+                                       free((char *)src_w_slash);
 
                                if (last - first < 1)
                                        bad = _("source directory is empty");
index 2975dcd581024cd483953b47636466b79c95bafe..4aa7023903374aa3ccea23d5fc9ae82c9c67bca7 100644 (file)
@@ -75,7 +75,7 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)
                return 0;
        } else if (!c->mode_from_env && !strcmp(k, "notes.rewritemode")) {
                if (!v)
-                       config_error_nonbool(k);
+                       return config_error_nonbool(k);
                c->combine = parse_combine_notes_fn(v);
                if (!c->combine) {
                        error(_("Bad notes.rewriteMode value: '%s'"), v);
index d7c9f32f0ce98112ddd4d4a8499b227b181e09e6..2ff036a0fa6c8e7b013d061d16baf33045305950 100644 (file)
@@ -152,8 +152,10 @@ struct git_istream *open_istream(const unsigned char *sha1,
        if (filter) {
                /* Add "&& !is_null_stream_filter(filter)" for performance */
                struct git_istream *nst = attach_stream_filter(st, filter);
-               if (!nst)
+               if (!nst) {
                        close_istream(st);
+                       return NULL;
+               }
                st = nst;
        }
 
diff --git a/utf8.c b/utf8.c
index 0d20e0acb2b6fb2dd1d63abed676a036b2b7ec2f..a831d5089908df61574119b01a29a1991196f63a 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -5,8 +5,8 @@
 /* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */
 
 struct interval {
-  int first;
-  int last;
+       ucs_char_t first;
+       ucs_char_t last;
 };
 
 size_t display_mode_esc_sequence_len(const char *s)
@@ -529,7 +529,7 @@ char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, int *outs
        while (1) {
                size_t cnt = iconv(conv, &cp, &insz, &outpos, &outsz);
 
-               if (cnt == -1) {
+               if (cnt == (size_t) -1) {
                        size_t sofar;
                        if (errno != E2BIG) {
                                free(out);