shader_set_function is inconsistent in whether it will cleanup the shader before returning an error. Most of the callers of shader_set_function will do the cleanup, which could double-free; but not all of them do, which means there are also potential leaks. So make sure all callers do, and remove shader_cleanup calls from shader_set_function.