From cac27a40d8197a514b59a8f850ce62340cec87a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Matellanes?= Date: Mon, 10 Aug 2015 20:08:54 +0200 Subject: [PATCH] msvcirt: Allocate a buffer if necessary when a file is opened. --- dlls/msvcirt/msvcirt.c | 1 + dlls/msvcirt/tests/msvcirt.c | 2 ++ 2 files changed, 3 insertions(+) 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);