davidchisnall / dtc

FreeBSD Device Tree Compiler
18 stars 17 forks source link

Coverity reports an illegal access #39

Closed kevans91 closed 6 years ago

kevans91 commented 6 years ago

Coverity reports the following:

*** CID 1385590:  Memory - illegal accesses  (WRAPPER_ESCAPE)
/usr.bin/dtc/fdt.cc: 1388 in dtc::fdt::device_tree::resolve_cross_references(unsigned int &)()
1382                                    path += node_name;
1383                                    if (node_address != string())
1384                                    {
1385                                            path += '@';
1386                                            path += node_address;
1387                                    }
>>>     CID 1385590:  Memory - illegal accesses  (WRAPPER_ESCAPE)
>>>     Using internal representation of destroyed object local "next".
1388                                    target = next;
1389                                    if (target == nullptr)
1390                                    {
1391                                            break;
1392                                    }
1393                            }

I'm not immediately sure what it's wanting here. I guess it might be upset because next is being assigned in the loop above to c.get() and c is local to the loop?

davidchisnall commented 6 years ago

This is a false positive. We're using unique_ptr for ownership here, but we guarantee that the unique_ptrs exist for the lifetime of the tree (certainly longer than the lifetime of this loop).