Sonar detected memory fixes (into release/iotplatfor-v1)

"Twin" PR: https://github.com/telefonicaid/fiware-orion/pull/502