# Freeing $1 from zend_language_parser.y

- Thread: https://externals.io/message/56396
- Original archive: https://news-web.php.net/php.internals/56396
- Started by Clint M Priest on 2011-11-18T14:28:36+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #56396 — Clint M Priest — 2011-11-18T14:28:36+00:00

URL: https://externals.io/message/56396#56396

Is there any reason I would have to free a pointer from the language_parser if I am just storing a reference to $1

I'm doing this:
CG(accessor_node) = &$1;

And in doing so it is causing a memory leak, only if I add:

efree($1.u.constant.value.str.val);

Does that memory leak go away.

-Clint

---

## #56399 — Felipe Pena — 2011-11-18T16:30:01+00:00

URL: https://externals.io/message/56396#56399 · In reply to: #56396

2011/11/18 Clint M Priest <cpriest@zerocue.com>:
> Is there any reason I would have to free a pointer from the language_parser if I am just storing a reference to $1
>
> I'm doing this:
> CG(accessor_node) = &$1;
>

This doesn't looks right, as &$1 points to the local variable in yyparse().

> And in doing so it is causing a memory leak, only if I add:
>
> efree($1.u.constant.value.str.val);
>

It's normal when not using the alloc'ed string into the op_array.

-- 
Regards,
Felipe Pena
