Il 20/09/2014 02:11, Amos Kong ha scritto: > Conscan complains about g_malloc0() and malloc() return null. > > Error: NULL_RETURNS (CWE-476): > qemu-kvm/qom/object.c:239: returned_null: Function "g_malloc0(gsize)" > returns null. > qemu-kvm/qom/object.c:239: var_assigned: Assigning: "ti->class" = null > return value from "g_malloc0(gsize)". > qemu-kvm/qom/object.c:249: dereference: Dereferencing a null pointer > "ti->class". > > But if the passed size parameter is >= 1, then we can always get an > effective pointer, the warning disappears.
The model should handle it: void * g_malloc0(size_t n_bytes) { void *mem; __coverity_negative_sink__(n_bytes); mem = calloc(1, n_bytes == 0 ? 1 : n_bytes); if (!mem) __coverity_panic__(); return mem; } So this patch means your coverity runs are misconfigured. Paolo