Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
Merged

Rel 5 #573

Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
26a10b2
Update Pybytes to version 1.6.1
Xykon Nov 23, 2020
d600b20
Update pycom_version.h
Xykon Nov 23, 2020
742cc14
Update _pybytes_protocol.py
Xykon Nov 23, 2020
8340e1e
version 1.20.2.r3
peter-pycom Dec 23, 2020
3f690a5
Fix an issue that Bluetooth init() failed after deinit()
geza-pycom Dec 28, 2020
826e233
Add API create_128bit_le_uuid_from_string()
geza-pycom Oct 20, 2020
684e9da
Fix a bug causing multi-heap assert exception in modcoap and improve …
geza-pycom Dec 29, 2020
627e39c
removed exit 0 condition for tests
msariisik Jan 7, 2021
8cd6d21
revert back exit 0 condition on Jenkins
msariisik Jan 11, 2021
120f929
Rtc utime fix (#206)
gijsio Jan 11, 2021
f04187b
update version to 1.20.2.r4
peter-pycom Jan 11, 2021
af93a22
Merge pull request #215 from pycom/release_v1.20.2.r4
gijsio Jan 11, 2021
bee94a2
Merge remote-tracking branch 'public/Dev' into release_v1.20.2.r4
peter-pycom Jan 12, 2021
ffb0e1c
Merge pull request #515 from pycom/release_v1.20.2.r4_again
Xykon Jan 12, 2021
12e32a6
add gps coordinates to the pygate json status
gijsio Aug 27, 2020
c046f5f
fixes the re-initialization of lora OTAA
gijsio Aug 27, 2020
21af0b7
Revert "add gps coordinates to the pygate json status"
gijsio Aug 27, 2020
a5dff88
fixed the timeout
gijsio Aug 27, 2020
6153b01
removed commented code
gijsio Jan 15, 2021
144e161
Fix problem in mod_coap_resource_callback_enable() which forbids to d…
geza-pycom Jan 21, 2021
ed4e191
Lora reinit fix (#219)
gijsio Jan 25, 2021
9499afd
vfs_littlefs_file.c: Prevent double close of a file
robert-hh Jan 31, 2021
8baf148
vfs_littlefs_file.c: Move tagging files as closed.
robert-hh Mar 4, 2021
9253101
Adjust the fix so calling other file operations (e.g. write, read etc…
geza-pycom Mar 7, 2021
39ca300
Adjust to be the same as FatFs
geza-pycom Mar 7, 2021
56dd0ed
Add the modified functionality to the regression tests
geza-pycom Mar 7, 2021
a37510c
Update Copyright header
Xykon Mar 9, 2021
a66cdec
sflash_diskio_littlefs.c: Enable block level wear-leveling
robert-hh Jan 14, 2021
bdebb49
sflash_diskio_littlefs.c: change block_cycles to 100
geza-pycom Mar 21, 2021
7d28bd1
mperror.c: Move noticing of the next heartbeat transition (#235)
geza-pycom Apr 10, 2021
46d4a31
LTE: fix conditional in lte_check_attached
Jan 20, 2021
aace45a
Define uart id as int instead of mp_obj
knagymate Feb 16, 2020
d6a17b1
machuart: change default to UART 1
peter-pycom Feb 19, 2021
4cf7273
fix mpy-cross build
peter-pycom Feb 19, 2021
efaea4d
thread: allocate internal mem
peter-pycom Jun 30, 2021
39de84e
Merge pull request #279 from pycom/thread_malloc
gijsio Jul 16, 2021
b596cea
micropython task: allocate internal ram
gijsio Jul 16, 2021
68c0063
Fix for the missing certificated in WPA2 Enterprise connection (#263)
VladPetrovici Jun 28, 2021
08cbc20
update pybytes 1.7.0 975e984
peter-pycom Sep 22, 2021
04a4454
bump version to 1.20.2.r5
peter-pycom Sep 22, 2021
e932a94
lora: Fix losing of multicast params
peter-pycom Oct 5, 2021
b3b1575
Merge branch 'Dev' of github.com:pycom/pycom-micropython-sigfox into …
peter-pycom Oct 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix a bug causing multi-heap assert exception in modcoap and improve …
…modcoap's memory handling (#208)

The following is fixed:

* Incorrectly called "free" on the "path" pointer, "path" pointer did not point to the correct memory area when free() was called
* Changed m_malloc and m_free to malloc and free because those objects not needed to be allocated on the Garbage Collector controlled heap
* Removed the "uri" member of "resource" object because it was not used
  • Loading branch information
geza-pycom authored Dec 29, 2020
commit 684e9da9ef75bd4c7dce73b2774b34b570859523
43 changes: 20 additions & 23 deletions esp32/mods/modcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ typedef struct mod_coap_resource_obj_s {
coap_resource_t* coap_resource;
struct mod_coap_resource_obj_s* next;
uint8_t* value;
unsigned char* uri;
uint32_t max_age;
uint16_t etag_value;
uint16_t value_len;
Expand Down Expand Up @@ -208,9 +207,10 @@ STATIC mod_coap_resource_obj_t* add_resource(const char* uri, uint8_t mediatype,
resource->next = NULL;

// uri parameter pointer will be destroyed, pass a pointer to a permanent location
resource->uri = m_malloc(strlen(uri));
memcpy(resource->uri, uri, strlen(uri));
resource->coap_resource = coap_resource_init((const unsigned char* )resource->uri, strlen(uri), 0);
unsigned char* uri_ptr = (unsigned char*)malloc(strlen(uri));
memcpy(uri_ptr, uri, strlen(uri));
// Pass COAP_RESOURCE_FLAGS_RELEASE_URI so Coap Library will free up the memory allocated to store the URI when the Resource is deleted
resource->coap_resource = coap_resource_init(uri_ptr, strlen(uri), COAP_RESOURCE_FLAGS_RELEASE_URI);
if(resource->coap_resource != NULL) {
// Add the resource to the Coap context
coap_add_resource(context->context, resource->coap_resource);
Expand Down Expand Up @@ -238,7 +238,7 @@ STATIC mod_coap_resource_obj_t* add_resource(const char* uri, uint8_t mediatype,
return resource;
}
else {
m_free(resource->uri);
free(uri_ptr);
m_del_obj(mod_coap_resource_obj_t, resource);
// Resource cannot be created
return NULL;
Expand Down Expand Up @@ -278,14 +278,12 @@ STATIC void remove_resource_by_key(coap_key_t key) {
previous->next = current->next;
}

// Free the URI
m_free(current->uri);
// Free the resource in coap's scope
coap_delete_resource(context->context, key);
// Free the element in MP scope
m_free(current->value);
free(current->value);
// Free the resource itself
m_free(current);
m_del_obj(mod_coap_resource_obj_t, current);

return;
}
Expand Down Expand Up @@ -320,7 +318,7 @@ STATIC void resource_update_value(mod_coap_resource_obj_t* resource, mp_obj_t ne

// Invalidate current data first
resource->value_len = 0;
m_free(resource->value);
free(resource->value);

if (mp_obj_is_integer(new_value)) {

Expand All @@ -334,7 +332,7 @@ STATIC void resource_update_value(mod_coap_resource_obj_t* resource, mp_obj_t ne
}

// Allocate memory for the new data
resource->value = m_malloc(resource->value_len);
resource->value = malloc(resource->value_len);
memcpy(resource->value, &value, sizeof(value));

} else {
Expand All @@ -344,7 +342,7 @@ STATIC void resource_update_value(mod_coap_resource_obj_t* resource, mp_obj_t ne
resource->value_len = value_bufinfo.len;

// Allocate memory for the new data
resource->value = m_malloc(resource->value_len);
resource->value = malloc(resource->value_len);
memcpy(resource->value, value_bufinfo.buf, resource->value_len);
}
}
Expand Down Expand Up @@ -748,16 +746,13 @@ STATIC coap_pdu_t * modcoap_new_request
// Helper function to create a new option for a request message
STATIC coap_list_t * modcoap_new_option_node(unsigned short key, unsigned int length, unsigned char *data) {

coap_list_t *node = m_malloc(sizeof(coap_list_t) + sizeof(coap_option) + length);
coap_list_t *node = malloc(sizeof(coap_list_t) + sizeof(coap_option) + length);
if (node) {
coap_option *option;
option = (coap_option *)(node->data);
COAP_OPTION_KEY(*option) = key;
COAP_OPTION_LENGTH(*option) = length;
memcpy(COAP_OPTION_DATA(*option), data, length);
} else {
m_free(node);
node = NULL;
}

return node;
Expand Down Expand Up @@ -937,7 +932,7 @@ STATIC mp_obj_t mod_coap_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map
// Only 1 context is supported currently
if(initialized == false) {

MP_STATE_PORT(coap_ptr) = m_malloc(sizeof(mod_coap_obj_t));
MP_STATE_PORT(coap_ptr) = m_new_obj(mod_coap_obj_t);
coap_obj_ptr = MP_STATE_PORT(coap_ptr);
coap_obj_ptr->context = NULL;
coap_obj_ptr->resources = NULL;
Expand Down Expand Up @@ -1235,19 +1230,21 @@ STATIC mp_obj_t mod_coap_send_request(mp_uint_t n_args, const mp_obj_t *pos_args
//TODO: allocate the proper length
size_t length = 300;
unsigned char* path = malloc(length);
int segments = coap_split_path(coap_uri.path.s, coap_uri.path.length, path, &length);
// Need to use a different pointer because when the segments are composed the pointer itself is moved
unsigned char* path_segment = path;
int segments = coap_split_path(coap_uri.path.s, coap_uri.path.length, path_segment, &length);

// Insert the segments as separate URI-Path options
while (segments--) {
node = modcoap_new_option_node(COAP_OPTION_URI_PATH, COAP_OPT_LENGTH(path), COAP_OPT_VALUE(path));
node = modcoap_new_option_node(COAP_OPTION_URI_PATH, COAP_OPT_LENGTH(path_segment), COAP_OPT_VALUE(path_segment));
if(node != NULL) {
LL_APPEND(coap_obj_ptr->optlist, node);
}

path += COAP_OPT_SIZE(path);
// Move the path_segment pointer to the next segment
path_segment += COAP_OPT_SIZE(path_segment);
}


// Free up the memory using the pointer pointing to the beginning of the memory area
free(path);

// Put Content Format option if given
Expand All @@ -1271,7 +1268,7 @@ STATIC mp_obj_t mod_coap_send_request(mp_uint_t n_args, const mp_obj_t *pos_args
while(coap_obj_ptr->optlist != NULL) {
next = coap_obj_ptr->optlist->next;
coap_obj_ptr->optlist->next = NULL;
m_free(coap_obj_ptr->optlist);
free(coap_obj_ptr->optlist);
coap_obj_ptr->optlist = next;
}

Expand Down