py: Fix vstr_init for case that alloc = 0.

pull/407/head
Damien George 2014-03-31 17:10:59 +01:00
rodzic 43e92cfb52
commit 8cd72bdf92
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -10,6 +10,10 @@
#define ROUND_ALLOC(a) (((a) & ((~0) - 7)) + 8)
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->len = 0;
vstr->buf = m_new(char, vstr->alloc);