Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Fix function get_config_bytes #3544

Closed
wants to merge 1 commit into from
Closed

Conversation

richlab
Copy link

@richlab richlab commented Dec 17, 2019

found error in switch, all cases returning same bytes-val

found error in switch, all cases returning same bytes-val
@blueimp
Copy link
Owner

blueimp commented Dec 17, 2019

Thanks for your contribution @richlab .
The get_config_bytes function however is correct in its current form.
You can test it out yourself here (without the overflow fix):
https://repl.it/repls/ClientsideLoudPoints

This is due to the way PHP's switch statement works:
https://www.php.net/manual/en/control-structures.switch.php

It is important to understand how the switch statement is executed in order to avoid mistakes. The switch statement executes line by line (actually, statement by statement). In the beginning, no code is executed. Only when a case statement is found whose expression evaluates to a value that matches the value of the switch expression does PHP begin to execute the statements. PHP continues to execute the statements until the end of the switch block, or the first time it sees a break statement. If you don't write a break statement at the end of a case's statement list, PHP will go on executing the statements of the following case.

@blueimp blueimp closed this Dec 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants