# fix for bug #26696

- Thread: https://externals.io/message/7059
- Original archive: https://news-web.php.net/php.internals/7059
- Started by Sterling Hughes on 2004-01-13T20:03:30+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #7059 — Sterling Hughes — 2004-01-13T20:03:30+00:00

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

Hey,

I've attached a fix for an engine level crash in switch() when it is
used with string offsets.  This eliminates a double-free and valgrind
reports that no new leaks have been introduced.

-Sterling

---

## #7061 — Andi Gutmans — 2004-01-13T21:01:18+00:00

URL: https://externals.io/message/7059#7061 · In reply to: #7059

Are you sure this is OK? It seems strange that string offsets don't need 
any unlocking. It might mean we have a problem someplace else and that 
you're fixing the cause and not the source of the problem (although I 
haven't had time to dig deep).
In general, consider the following code:
$a = "Foo";

switch ($a[0]) {
         case 'b':
                 break;
         case 'c':
                 break;
         case 'F':
                 break;
}

Are you sure this doesn't leak now? I don't have time to look at it now, 
but if you are absolutely convinced the patch makes sense I'll try and step 
through it with a debugger as soon as I have some free time.

BTW, thanks for taking a look at it.
Andi

At 03:03 PM 1/13/2004 -0500, Sterling Hughes wrote:
>Hey,
>
>I've attached a fix for an engine level crash in switch() when it is
>used with string offsets.  This eliminates a double-free and valgrind
>reports that no new leaks have been introduced.
>
>-Sterling

---

## #7062 — Sterling Hughes — 2004-01-13T21:06:44+00:00

URL: https://externals.io/message/7059#7062 · In reply to: #7061

> Are you sure this is OK? It seems strange that string offsets don't need 
> any unlocking. It might mean we have a problem someplace else and that 
> you're fixing the cause and not the source of the problem (although I 
> haven't had time to dig deep).
> In general, consider the following code:
> $a = "Foo";
> 
> switch ($a[0]) {
>         case 'b':
>                 break;
>         case 'c':
>                 break;
>         case 'F':
>                 break;
> }
> 
> Are you sure this doesn't leak now? I don't have time to look at it now, 
> but if you are absolutely convinced the patch makes sense I'll try and step 
> through it with a debugger as soon as I have some free time.
>

No, I was wrong.  I hate the memory manager, it cleans up my leaks for
me - makes it impossible to rely on valgrind.  ;) Anyway to turn that off?

I'm playing around some more now.

-Sterling
