[runtime]Add some error checking to custom attr parsing and plug a memory leak. Fixes #13435.