Commit 9ec27408 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite/layout: Fail to create layouts with negative size.

parent 9c138562
......@@ -5207,6 +5207,9 @@ HRESULT create_textlayout(const struct textlayout_desc *desc, IDWriteTextLayout
*layout = NULL;
if (desc->max_width < 0.0f || desc->max_height < 0.0f)
return E_INVALIDARG;
if (!desc->format || !desc->string)
return E_INVALIDARG;
......
......@@ -908,7 +908,7 @@ static void test_CreateTextLayout(void)
factory = create_factory();
layout = (void*)0xdeadbeef;
hr = IDWriteFactory_CreateTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, &layout);
hr = IDWriteFactory_CreateTextLayout(factory, NULL, 0, NULL, 0.0f, 0.0f, &layout);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(layout == NULL, "got %p\n", layout);
......@@ -941,6 +941,21 @@ static void test_CreateTextLayout(void)
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(layout == NULL, "got %p\n", layout);
layout = (void *)0xdeadbeef;
hr = IDWriteFactory_CreateTextLayout(factory, L"string", 6, format, -100.0f, 100.0f, &layout);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(layout == NULL, "Unexpected pointer %p.\n", layout);
layout = (void *)0xdeadbeef;
hr = IDWriteFactory_CreateTextLayout(factory, L"string", 6, format, 100.0f, -100.0f, &layout);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(layout == NULL, "Unexpected pointer %p.\n", layout);
layout = (void *)0xdeadbeef;
hr = IDWriteFactory_CreateTextLayout(factory, L"string", 6, format, -100.0f, -100.0f, &layout);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(layout == NULL, "Unexpected pointer %p.\n", layout);
hr = IDWriteFactory_CreateTextLayout(factory, L"string", 0, format, 0.0f, 0.0f, &layout);
ok(hr == S_OK, "Failed to create text layout, hr %#x.\n", hr);
IDWriteTextLayout_Release(layout);
......@@ -1031,7 +1046,7 @@ static void test_CreateGdiCompatibleTextLayout(void)
factory = create_factory();
layout = (void*)0xdeadbeef;
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout);
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0f, 0.0f, 0.0f, NULL, FALSE, &layout);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(layout == NULL, "got %p\n", layout);
......@@ -1070,6 +1085,24 @@ static void test_CreateGdiCompatibleTextLayout(void)
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(layout == NULL, "got %p\n", layout);
layout = (void *)0xdeadbeef;
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, L"string", 6, format, -100.0f, 100.0f, 1.0f,
NULL, FALSE, &layout);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(layout == NULL, "Unexpected pointer %p.\n", layout);
layout = (void *)0xdeadbeef;
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, L"string", 6, format, 100.0f, -100.0f, 1.0f,
NULL, FALSE, &layout);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(layout == NULL, "Unexpected pointer %p.\n", layout);
layout = (void *)0xdeadbeef;
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, L"string", 6, format, -100.0f, -100.0f, 1.0f,
NULL, FALSE, &layout);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(layout == NULL, "Unexpected pointer %p.\n", layout);
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, L"string", 6, format, 100.0f, 100.0f, 1.0f, NULL,
FALSE, &layout);
ok(hr == S_OK, "Failed to create text layout, hr %#x.\n", hr);
......
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