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

About SIGSEGV (Address boundary error) when using C++ PList::Array #255

Open
olongchaa opened this issue Feb 3, 2024 · 0 comments
Open

Comments

@olongchaa
Copy link

olongchaa commented Feb 3, 2024

I noticed that when using the PList::Array constructor. If array_fill is called to construct an Array object, the size will be incorrect.

static void array_fill(Array *_this, std::vector<Node*> &array, plist_t node)
{
    plist_array_iter iter = NULL;
    plist_array_new_iter(node, &iter);
    plist_t subnode;
    do {
        subnode = NULL;
        plist_array_next_item(node, iter, &subnode);
        array.push_back( Node::FromPlist(subnode, _this) );
    } while (subnode);
    free(iter);
}

It seems that the problem is here in the do while loop. Regardless of whether there are elements in plist_array, an element will be pushed_back, causing the size to not match the actual size. Is this normal?

At present, I have added judgment conditions myself.

static void array_fill(Array *_this, std::vector<Node*> &array, plist_t node)
{
    plist_array_iter iter = NULL;
    plist_array_new_iter(node, &iter);
    plist_t subnode;
    do {
        subnode = NULL;
        plist_array_next_item(node, iter, &subnode);
        if (subnode) {
            array.push_back( Node::FromPlist(subnode, _this) );
        }
    } while (subnode);
    free(iter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant