Unverified Commit 595ecd5f authored by huangzhw's avatar huangzhw Committed by GitHub
Browse files

sdscatfmt call sdsMakeRoomFor, asked for more space than intended (#8286)

instead of asking for the extra new space it wanted, it asked to grow the
string by the size it already has too.
i.e. a string of 1000 bytes, needing to grow by 10 bytes, would have been
asking for an **additional** 1010 bytes.
parent 324070c8
...@@ -642,7 +642,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) { ...@@ -642,7 +642,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
/* To avoid continuous reallocations, let's start with a buffer that /* To avoid continuous reallocations, let's start with a buffer that
* can hold at least two times the format string itself. It's not the * can hold at least two times the format string itself. It's not the
* best heuristic but seems to work in practice. */ * best heuristic but seems to work in practice. */
s = sdsMakeRoomFor(s, initlen + strlen(fmt)*2); s = sdsMakeRoomFor(s, strlen(fmt)*2);
va_start(ap,fmt); va_start(ap,fmt);
f = fmt; /* Next format specifier byte to process. */ f = fmt; /* Next format specifier byte to process. */
i = initlen; /* Position of the next byte to write to dest str. */ i = initlen; /* Position of the next byte to write to dest str. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment