Fixed potential NULL pointer and leak when setting node metadata