[PATCH v5 3/6] ncrypt/tests: Test NCryptFreeObject function.

Santino Mazza mazzasantino1206 at gmail.com
Wed Feb 16 11:50:48 CST 2022


On 16/2/22 14:45, Hans Leidekker wrote:

> On Wed, 2022-02-16 at 14:18 -0300, Santino Mazza wrote:
>>> +    buf = calloc(1, 50);
>>> +    ret = NCryptFreeObject((NCRYPT_KEY_HANDLE)buf);
>>> +    ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
>>> +    free(buf);
>>> +    }
>>> +}
>>> +
>>>    START_TEST(ncrypt)
>>>    {
>>>        test_key_import_rsa();
>>> +    test_ncrypt_free_object();
>>>    }
>> Hello Hans, what is the reason of using calloc instead of just malloc at
>> the end of the function?
> calloc() initializes the memory so this avoids the (small) risk that garbage
> bytes constitute a valid header, leading to a test failure or crash.
>
>
Interesting, didn't know that. Thanks!



More information about the wine-devel mailing list