SimpleSHM icon indicating copy to clipboard operation
SimpleSHM copied to clipboard

Reserved block size could be too small

Open gwyn opened this issue 13 years ago • 1 comments

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

gwyn avatar Jul 23 '12 22:07 gwyn

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.

abiusx avatar Feb 06 '17 22:02 abiusx