mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Enforce buffer length in utf8_encode definition (#589)
Fixes: https://github.com/quickjs-ng/quickjs/issues/464
This commit is contained in:
parent
416dde8458
commit
681568353c
2 changed files with 2 additions and 2 deletions
2
cutils.c
2
cutils.c
|
@ -246,7 +246,7 @@ size_t utf8_encode_len(uint32_t c)
|
|||
No null byte is stored after the encoded bytes.
|
||||
Return value is in range 1..4
|
||||
*/
|
||||
size_t utf8_encode(uint8_t *buf, uint32_t c)
|
||||
size_t utf8_encode(uint8_t buf[minimum_length(UTF8_CHAR_LEN_MAX)], uint32_t c)
|
||||
{
|
||||
if (c < 0x80) {
|
||||
buf[0] = c;
|
||||
|
|
2
cutils.h
2
cutils.h
|
@ -481,7 +481,7 @@ enum {
|
|||
};
|
||||
int utf8_scan(const char *buf, size_t len, size_t *plen);
|
||||
size_t utf8_encode_len(uint32_t c);
|
||||
size_t utf8_encode(uint8_t *buf, uint32_t c);
|
||||
size_t utf8_encode(uint8_t buf[minimum_length(UTF8_CHAR_LEN_MAX)], uint32_t c);
|
||||
uint32_t utf8_decode_len(const uint8_t *p, size_t max_len, const uint8_t **pp);
|
||||
uint32_t utf8_decode(const uint8_t *p, const uint8_t **pp);
|
||||
size_t utf8_decode_buf8(uint8_t *dest, size_t dest_len, const char *src, size_t src_len);
|
||||
|
|
Loading…
Reference in a new issue