igrr / axtls-8266

axTLS port for ESP8266
Other
79 stars 33 forks source link

Fix memory leak of ext_host_name in ssl_ext structure #49

Closed earlephilhower closed 7 years ago

earlephilhower commented 7 years ago

@Jeroen88 found a memory leak in axtls where the new ext_host_name pointer was leaking on every SSL reconnection, eventually eating up all RAM and crashing the chip (see https://github.com/esp8266/Arduino/issues/3428 ).

This patch just checks if we actually set a host name (strdup()d on the heap), and if so just frees it on the ssl_ext_free call. This should eliminate the leakage.

earlephilhower commented 7 years ago

Oops, this one accidentally included the other commit I'd sent in.

I'll submit a new PR later tonight from a clean branch to avoid it pulling in bc27f4b . Looks like I'll need to destroy my existing repo and re-fork, but it shouldn't be a big deal.