Commit 8cd72bdf authored by Damien George's avatar Damien George
Browse files

py: Fix vstr_init for case that alloc = 0.

parent 43e92cfb
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#define ROUND_ALLOC(a) (((a) & ((~0) - 7)) + 8) #define ROUND_ALLOC(a) (((a) & ((~0) - 7)) + 8)
void vstr_init(vstr_t *vstr, int alloc) { void vstr_init(vstr_t *vstr, int alloc) {
if (alloc < 2) {
// need at least 1 byte for the null byte at the end
alloc = 2;
}
vstr->alloc = alloc; vstr->alloc = alloc;
vstr->len = 0; vstr->len = 0;
vstr->buf = m_new(char, vstr->alloc); vstr->buf = m_new(char, vstr->alloc);
......
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