Commit 60eb44d8 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Don't touch _bufsiz value while initializing FILE structure.

parent fffbc8e5
......@@ -458,9 +458,11 @@ static int msvcrt_init_fp(MSVCRT_FILE* file, int fd, unsigned stream_flags)
*MSVCRT__errno() = MSVCRT_EBADF;
return -1;
}
memset(file, 0, sizeof(*file));
file->_ptr = file->_base = NULL;
file->_cnt = 0;
file->_file = fd;
file->_flag = stream_flags;
file->_tmpfname = NULL;
TRACE(":got FILE* (%p)\n",file);
return 0;
......
......@@ -1628,7 +1628,7 @@ static void test_fopen_s( void )
const char name[] = "empty1";
char buff[16];
unsigned char *ubuff = (unsigned char*)buff;
FILE *file;
FILE *file, *file2;
int ret;
int len;
......@@ -1719,6 +1719,22 @@ static void test_fopen_s( void )
ubuff[0], ubuff[1], ubuff[2]);
fclose(file);
/* test initial FILE values */
memset(file, 0xfe, sizeof(*file));
file->_flag = 0;
ret = p_fopen_s(&file2, name, "r");
ok(!ret, "fopen_s failed with %d\n", ret);
ok(file == file2, "file != file2 %p %p\n", file, file2);
ok(!file->_ptr, "file->_ptr != NULL\n");
ok(!file->_cnt, "file->_cnt != 0\n");
ok(!file->_base, "file->_base != NULL\n");
ok(file->_flag == 1, "file->_flag = %x\n", file->_flag);
ok(file->_file, "file->_file == 0\n");
ok(file->_charbuf == 0xfefefefe, "file->_charbuf = %x\n", file->_charbuf);
ok(file->_bufsiz == 0xfefefefe, "file->_bufsiz = %x\n", file->_bufsiz);
ok(!file->_tmpfname, "file->_tmpfname != NULL\n");
fclose(file2);
ok(_unlink(name) == 0, "Couldn't unlink file named '%s'\n", name);
}
......@@ -2273,7 +2289,6 @@ static void test_write_flush(void)
file = fopen(tempf, "wb+");
ok(file != NULL, "unable to create test file\n");
iobuf[0] = 0;
fwrite(iobuf, 1, 1, file); /* needed for wine to init _bufsiz */
ok(file->_bufsiz == 4096, "incorrect default buffer size: %d\n", file->_bufsiz);
test_write_flush_size(file, file->_bufsiz);
setvbuf(file, iobuf, _IOFBF, sizeof(iobuf));
......
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