diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c index 30681681c1..c0d88f9751 100644 --- a/builtin/mailsplit.c +++ b/builtin/mailsplit.c @@ -232,7 +232,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare, do { peek = fgetc(f); - } while (isspace(peek)); + } while (peek >= 0 && isspace(peek)); ungetc(peek, f); if (strbuf_getwholeline(&buf, f, '\n')) { diff --git a/mailinfo.c b/mailinfo.c index a489d9d0fb..659136cc58 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -1094,7 +1094,7 @@ int mailinfo(struct mailinfo *mi, const char *msg, const char *patch) do { peek = fgetc(mi->input); - } while (isspace(peek)); + } while (peek >= 0 && isspace(peek)); ungetc(peek, mi->input); /* process the email header */