Fix unlikely memory leak in ESL
Handle potential malloc failure better
Avoid dereferencing potential null value
Remove assignment without effect
Avoid dereferencing potential null value