Code

correct argument checking test for git hash-object
[git.git] / builtin-mailinfo.c
index 4b8261552a21d1ff074e10cbcf3d79194c7c8281..f974b9df968c74c5d62d58b2a09493e6abb4322e 100644 (file)
@@ -115,10 +115,10 @@ static void handle_from(const struct strbuf *from)
         * the () pair at the end.
         */
        strbuf_trim(&f);
-       if (f.buf[0] == '(')
-               strbuf_remove(&name, 0, 1);
-       if (f.len && f.buf[f.len - 1] == ')')
+       if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') {
+               strbuf_remove(&f, 0, 1);
                strbuf_setlen(&f, f.len - 1);
+       }
 
        get_sane_name(&name, &f, &email);
        strbuf_release(&f);
@@ -225,10 +225,9 @@ static void cleanup_subject(struct strbuf *subject)
                        continue;
                case '[':
                        if ((pos = strchr(subject->buf, ']'))) {
-                               remove = pos - subject->buf + 1;
-                               /* Don't remove too much. */
-                               if (remove <= (subject->len - remove + 1) * 2) {
-                                       strbuf_remove(subject, 0, remove);
+                               remove = pos - subject->buf;
+                               if (remove <= (subject->len - remove) * 2) {
+                                       strbuf_remove(subject, 0, remove + 1);
                                        continue;
                                }
                        } else