OpenWaterAnalytics / EPANET

The Water Distribution System Hydraulic and Water Quality Analysis Toolkit
MIT License
273 stars 203 forks source link

Bugfix #744

Closed 0tkl closed 11 months ago

0tkl commented 11 months ago

We're going to use EPANET in some serious scenarios which requires passing the static analyzer.

We fixed all problems reported in gcc static analyzer -fanalyzer, and all but problems in "Unused code" category in Clang analyzer scan-build.

0tkl commented 11 months ago

Changes:

  1. In addlinkvertex(), when realloc failed and pointer pointed to NULL, free the old array.
    (The previous version of my code just leave the pointer unchanged when realloc failed, due to my misconception of its expected behavior.)
  2. Apply your comments in xstrcpy().
  3. In ENR_getNetSize(), use the way that is consistent with other functions in epanet_output.c to handle allocation failures.
0tkl commented 11 months ago

OK, I reverted it.

LRossman commented 11 months ago

Thank you @0tkl for your contribution.