libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
382 stars 55 forks source link

[beken-72xx] Free list returned by wlan_sta_scan_result() #226

Closed szupi-ipuzs closed 6 months ago

szupi-ipuzs commented 6 months ago

This method might return a dynamically allocated buffer which should be freed by the caller (the example code does it). Not doing this results in memory leaks.

szupi-ipuzs commented 6 months ago

Ok, as you can see I decided to make the scanAlloc() method return the number of succesfully allocated items. This can help if realloc() fails - then we still can use the previously allocated buffer if needed. Making this method private should be done as a separate change, since it probably isn't the only one that should be moved.

I have tested this code shortly on bk7231, but not on realtek, since I do not own any realtek device atm (only checked compilation).