[Tile-serving] [osm2pgsql] Cleanup based on the output of LLVM's static analyzer (#299)

Daniel J. H. notifications at github.com
Sat Feb 21 17:51:54 UTC 2015


>          int nodec;
>  
> +        assert(ndc > 0 && "no nodes to proccess");

I added the assertion, because otherwise your old code would have done a malloc(0), which quoting the docs
> returns either NULL, or a unique pointer value that can later be successfully passed to free()

only passing it to free is guaranteed to work, but not e.g. dereferencing it, even in cases where it is _not_ a null pointer.

It's the same with &nodev[0]; if ndc == 0, &nodev[0] is illegal (this could even be simplified in C++11 with nodev.data() which returns nullptr in this case).

If ndc == 0 can indeed happen, the code has to be rewritten with this in mind.

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/299/files#r25123971
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20150221/89ee7fe2/attachment.html>


More information about the Tile-serving mailing list