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

Read buffer in INI::Is_Declaration_Of_Type is written on #930

Open
xezon opened this issue May 28, 2023 · 2 comments
Open

Read buffer in INI::Is_Declaration_Of_Type is written on #930

xezon opened this issue May 28, 2023 · 2 comments

Comments

@xezon
Copy link
Contributor

xezon commented May 28, 2023

Read buffer in INI::Is_Declaration_Of_Type is written on to accommodate the parsing.

char c = buffer[block_type_len];
buffer[block_type_len] = 0;

if (strcasecmp(block_type.Str(), buffer) != 0) {
    ret = false;
}

buffer[block_type_len] = c;
buffer += block_type_len;

The better approach is to compare with a max length.

@xezon
Copy link
Contributor Author

xezon commented May 28, 2023

A few lines below there is

while (strlen(buffer) != 0) {
    ret = ret && isspace(*buffer);
    buffer++;
}

This is poor algorithm. There is no need to strlen() after incrementing position by one.

@xezon
Copy link
Contributor Author

xezon commented May 28, 2023

Same in INI::Is_End_Of_Block function.

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

No branches or pull requests

1 participant