-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix MDNS crash on S2 #6193
Fix MDNS crash on S2 #6193
Conversation
@@ -117,6 +117,11 @@ mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *servic | |||
next = next->next; | |||
} | |||
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_results, NULL)); | |||
// The empty tuple object is shared and stored in flash so return early if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mp_obj_new_tuple already sets the length to n, so instead of special casing num_results == 0, you can remove the assignment of len below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set it to added
below in case we can make the wrapper objects for all of the results. So, it may be different than the value at alloc time. Want me to make it compare the current len vs added and then set it if different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urp .. tuples are meant to be static in size, I'm not sure of the impact of truncating one after initial allocation. but the tuple at this point is not seen by python code, so it doesn't matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
@@ -117,6 +117,11 @@ mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *servic | |||
next = next->next; | |||
} | |||
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_results, NULL)); | |||
// The empty tuple object is shared and stored in flash so return early if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urp .. tuples are meant to be static in size, I'm not sure of the impact of truncating one after initial allocation. but the tuple at this point is not seen by python code, so it doesn't matter.
If memory is at a premium, it would be better to change this into an iterator object, even if it's a bit more work. doing this before the next 7.x.0 would be good so that it wasn't an incompatible API change. |
Fixes #6186