| hermann on Fri, 02 Oct 2026 03:25:50 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: utf8 library for GP (!) |
On 2026-10-01 23:09, Bill Allombert wrote:
Nice, I tried to figure out whether that can be harmful and since it is done in attached gp code, I looked at pari_strchr, cgetg in "kernel/none/level1.h", avma, pari_mainstack, ... and got a bit lost. It seems memory allocations are done from top down. Question is whether whether it can ever happenDear PARI-dev,I wrote a basic script to convert UTF8 strings to code word and back in GP.
that strchr() can be at very top of allocated stack?Since pari_strchr() allocates one more than length long with cgetg(len+1, t_STR) to finally end string with "*s = 0" for char s, there should be 8 0-bytes at the end on 64bit Linux, and not only 1. Otherwise "strchr([0x23,0x23,0x23,0x23,0x23,0x23,0x23,0xF0])" could be a problem since F0 signals a 4 byte UTF-8 character, but nothing follows. That could crash other code, but since additional allocation for 0-byte at end allocates
8 bytes all is fine for pari? Regards, Hermann.