Merge branch 'jk/janitorial-fixes'

* 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
This commit is contained in:
Junio C Hamano 2014-03-14 14:24:37 -07:00
commit 7aab05d2b4
4 changed files with 9 additions and 6 deletions

View 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");

View 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);

View 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;
}

6
utf8.c
View File

@ -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);