Fix the high-impact issues from the code analysis report from customer See merge request espressif/esp-idf!16155