Fix buggy memory allocation introduced in #5152: 1) clean up ast_stack to reflect AST node rearrangement when necessary, to avoid dangling pointer; 2) call free_attr() on unused attribute list when no new syntax node is created, to avoid leaking it.
libcache