api.c: Release io_data->ptr when releasing io_data in io_free()
api.c: Release apisock on error in api()
util.c: Decreasing reference count on allocated JSON obects to prevent memory leak
Merge pull request #521 from mborodin/upstream

Some meory leaks fixed