X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fgit.git;a=blobdiff_plain;f=quote.c;h=24a58ba454fdfd04dd441d787ea8202ea772c02f;hp=c8ba6b397a00036104278a8e55e154079018bb19;hb=d4a98e701f86bdff469d0f1ed912ba1651c23c3f;hpb=eb35c18e426e9a05e1007859f41f56dd0b25e40f diff --git a/quote.c b/quote.c index c8ba6b397a..24a58ba454 100644 --- a/quote.c +++ b/quote.c @@ -48,6 +48,12 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src) static const char ok_punct[] = "+,-./:=@_^"; const char *p; + /* Avoid losing a zero-length string by adding '' */ + if (!*src) { + strbuf_addstr(dst, "''"); + return; + } + for (p = src; *p; p++) { if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) { sq_quote_buf(dst, src);