diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index bf89650ac0f..7caa05b4b61 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -973,6 +973,7 @@ filebuf* __thiscall filebuf_open(filebuf *this, const char *name, ios_open_mode _close(fd); } else this->fd = fd; + streambuf_allocate(&this->base); streambuf_unlock(&this->base); return (this->fd == -1) ? NULL : this; } diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c index e0bda56339a..0977173c696 100644 --- a/dlls/msvcirt/tests/msvcirt.c +++ b/dlls/msvcirt/tests/msvcirt.c @@ -1016,9 +1016,11 @@ static void test_filebuf(void) pret = (filebuf*) call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_ate|OPENMODE_nocreate|OPENMODE_noreplace|OPENMODE_binary, filebuf_openprot); ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret); + ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated); fb1.base.do_lock = 0; pret = (filebuf*) call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_out, filebuf_openprot); ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret); + ok(fb1.base.allocated == 1, "wrong allocate value, expected 1 got %d\n", fb1.base.allocated); ok(_write(fb1.fd, "testing", 7) == 7, "_write failed\n"); pret = (filebuf*) call_func1(p_filebuf_close, &fb1); ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);