KalleOlaviNiemitalo commented on code in PR #1798:
URL: https://github.com/apache/avro/pull/1798#discussion_r934747453
##########
lang/c/src/schema.c:
##########
@@ -48,20 +50,25 @@ static void avro_schema_init(avro_schema_t schema,
avro_type_t type)
static int is_avro_id(const char *name)
{
- size_t i, len;
+ setlocale(LC_ALL, "en_US.UTF-8");
if (name) {
- len = strlen(name);
- if (len < 1) {
- return 0;
- }
- for (i = 0; i < len; i++) {
- if (!(isalpha(name[i])
- || name[i] == '_' || (i && isdigit(name[i])))) {
+ size_t len = strlen(name);
+ if (len < 1) {
+ return 0;
+ }
+ size_t mbslen = mbstowcs(NULL, name, 0);
+ wchar_t wsName[mbslen + 1];
+ mbstowcs(wsName, name, mbslen + 1);
+ size_t i;
+ for (i = 0; i < mbslen; i++) {
+ if (!(iswalpha(wsName[i])
+ || wsName[i] == '_' || (i && isdigit(wsName[i])))) {
Review Comment:
`isdigit` is not correct here anyway, because it requires that the input is
either `EOF` or an `unsigned char`. If you give it an out-of-range value, then
it may read beyond the end of a lookup table.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]