Skip to content

Commit

Permalink
mDNS malloc error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
habazut committed Nov 16, 2024
1 parent 1235c28 commit 9602c32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions EXmDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int MDNS::begin(const IPAddress& ip, char* name) {
// delay(100);

_ipAddress = ip;
_name = (char *)malloc(strlen(name +2));
_name = (char *)malloc(strlen(name)+2);
byte n;
for(n = 0; n<strlen(name); n++)
_name[n+1] = name[n];
Expand All @@ -87,7 +87,7 @@ int MDNS::begin(const IPAddress& ip, char* name) {

int MDNS::addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_t proto) {
// we ignore proto, assume TCP
_serviceName = (char *)malloc(strlen(name +2));
_serviceName = (char *)malloc(strlen(name)+2);
byte n;
for(n = 0; n<strlen(name); n++)
_serviceName[n+1] = name[n];
Expand Down
4 changes: 2 additions & 2 deletions STM32lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
//#define LWIP_DEBUG 1
//#define TCP_DEBUG LWIP_DBG_ON

// IMPORTANT CHANGE THE FIRST ONE
// NOT STRICT NECESSARY ANY MORE BUT CAN BE USED TO SAVE RAM
#undef MEM_LIBC_MALLOC
#define MEM_LIBC_MALLOC 1 // critical, fixes heap trashing
#define MEM_LIBC_MALLOC 1 // use the same malloc as for everything else
#undef MEMP_MEM_MALLOC
#define MEMP_MEM_MALLOC 1 // uses malloc which means no pools which means slower but not mean 32KB up front

Expand Down

0 comments on commit 9602c32

Please sign in to comment.