fix: check return values of malloc()/strdup()/realloc()
fix: check return values of fcntl()
new: add a free_hap_status() function for proper cleanup
fix: check return value of new_hap_status()