Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserved block size could be too small #1

Open
gwyn opened this issue Jul 23, 2012 · 1 comment
Open

Reserved block size could be too small #1

gwyn opened this issue Jul 23, 2012 · 1 comment

Comments

@gwyn
Copy link

gwyn commented Jul 23, 2012

Hello Klaus,

I believe there is a problem with this line:
$size = mb_strlen($data, 'UTF-8');

It returns the number of UTF-8 characters in $data. As UTF-8 is a multi-byte encoding, this number can vary from the actual length in bytes. This means the string would not fit into the reserved shared memory block.

The following fix would return the number of bytes:
$size = mb_strlen($data, '8bit');

Best regards,
gwyn

@abiusx
Copy link

abiusx commented Feb 6, 2017

Yes I wanted to say the same thing. You need the number of bytes not characters.
Also, only increase size if necessary. No need to shrink. Or put a threshold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants