Skip to content

WebServer::authenticate uses wrong braces in malloc #9007

Closed
@TD-er

Description

@TD-er

Board

Any

Device Description


Hardware Configuration


Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

Windows 11

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

115200

Description

C:/Users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp:138:54: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  138 |       char *toencode = (char *)malloc[toencodeLen + 1];
      |                                                      ^
cc1plus.exe: warning: pointer to a function used in arithmetic [-Wpointer-arith]

Took a while to see what was wrong here, but the code uses malloc[] instead of malloc()

At the end of the compile run, it also states other resulting errors:

C:/Users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp: In member function 'authenticate':
C:/Users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp:146:13: warning: 'free' called on unallocated object 'malloc' [-Wfree-nonheap-object]
  146 |         free(toencode);
      |             ^
c:\users\gijsn\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\sys-include\stdlib.h:112:10: note: declared here
  112 | void    *malloc(size_t) __malloc_like __result_use_check __alloc_size(1) _NOTHROW;
      |          ^
C:/Users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp:152:13: warning: 'free' called on unallocated object 'malloc' [-Wfree-nonheap-object]
  152 |         free(toencode);
      |             ^
c:\users\gijsn\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\sys-include\stdlib.h:112:10: note: declared here
  112 | void    *malloc(size_t) __malloc_like __result_use_check __alloc_size(1) _NOTHROW;
      |          ^
C:/Users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.cpp:156:11: warning: 'free' called on unallocated object 'malloc' [-Wfree-nonheap-object]
  156 |       free(toencode);
      |           ^
c:\users\gijsn\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\sys-include\stdlib.h:112:10: note: declared here
  112 | void    *malloc(size_t) __malloc_like __result_use_check __alloc_size(1) _NOTHROW;
      |          ^

Sketch

---

Debug Message

---

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions