[Freeipa-devel] [PATCHES] 101-107 Fixes for various Coverity issues
Martin Kosek
mkosek at redhat.com
Wed Feb 27 12:55:27 UTC 2013
On 02/27/2013 01:39 PM, Martin Kosek wrote:
> On 02/27/2013 12:35 PM, Sumit Bose wrote:
>> Hi,
>>
>> the attached patches 102-107 fix issues found by Coverity which are
>> tracked by tickets #3422-#3427 and remove an unused variable
>> (patch 101).
>>
>> bye,
>> Sumit
>>
>
> I see just one issue. In patch 0105:
>
> - global_ipactx = (struct ipa_context *)malloc(sizeof(global_ipactx));
> + global_ipactx = (struct ipa_context *)malloc(sizeof(*global_ipactx));
>
> I do not think this will work right. *global_ipactx will just de-reference
> global_ipactxt and run sizeof on the result, right?
>
> I would prefer this change:
>
> global_ipactx = (struct ipa_context *)malloc(sizeof(struct ipa_context *));
>
> Martin
>
We just discussed this in Brno - in fact your change should be right as you
allocate memory for the whole structure and not just a pointer to the structure
(though I personally would prefer sizeof(struct ipa_context) as it is clearer).
Hmrph, C language 101 revisited :-)
Martin
More information about the Freeipa-devel
mailing list