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

json_object_array_del_idx function has segment fault error? #247

Closed
jalnanco opened this issue Aug 5, 2016 · 3 comments
Closed

json_object_array_del_idx function has segment fault error? #247

jalnanco opened this issue Aug 5, 2016 · 3 comments

Comments

@jalnanco
Copy link

jalnanco commented Aug 5, 2016

I made an array to take three json_objects.
When I use json_object_array_del_idx function it has error like this

save part

        json_object *my_object = json_object_new_object();
        json_object_object_add(my_object, "EUI64", json_object_new_int64(eui64.llvalue));
        json_object_object_add(my_object, "nodeId", json_object_new_int(nodeId.lvalue)); 
        json_object_object_add(my_object, "Key", json_object_new_int(globalKey.lvalue));
        json_object_array_add(pairArray, my_object);

delete part

int targetIndex = searchPairWithEUI64(pairArray, eui64);
if(targetIndex != -1) {
    if(json_object_array_del_idx(pairArray, targetIndex, 1) == 0 ) {
        emberSerialPrintf(APP_SERIAL,"Delete Success\r\n");
    }
}

the result in delete part:
Segmentation fault (core dumped)

@hawicz
Copy link
Member

hawicz commented Aug 5, 2016

There's nothing obviously wrong in those few lines of code you listed but you're not providing enough information to figure out anything at all.
Where does it crash? Have you checked targetIndex vs the size of pairArray to ensure it's in range? Do you have a minimal test case that shows the problem?

@jalnanco
Copy link
Author

jalnanco commented Aug 8, 2016

I think It might be my mistake.
I should make a code and test it again.
Sorry for bother you. this is not enough explained.
Anyway, Thank you for reply

@hawicz
Copy link
Member

hawicz commented Aug 9, 2016

Ok, good luck finding the bug. If it turns out to be a problem in json-c, please re-open this issue.

@hawicz hawicz closed this as completed Aug 9, 2016
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

2 participants