pupnp / pupnp

libupnp: Build UPnP-compliant control points, devices, and bridges on several operating systems.
https://pupnp.github.io/pupnp
BSD 3-Clause "New" or "Revised" License
353 stars 117 forks source link

Fix crash when using log callbacks #332

Closed whyman closed 2 years ago

whyman commented 2 years ago

va_list cannot be used multiple times and causes a crash

mrjimenez commented 2 years ago

Build / Build (ubuntu-16.04) - Debug (pull_request) Build / Build (ubuntu-16.04) - Release (pull_request)

/home/runner/work/pupnp/pupnp/upnp/src/api/UpnpLog.cpp: In constructor ‘UpnpLog::UpnpLog()’:
/home/runner/work/pupnp/pupnp/upnp/src/api/UpnpLog.cpp:20:11: error: ‘nullptr’ was not declared in this scope
 , m_logFp(nullptr)
           ^
/home/runner/work/pupnp/pupnp/upnp/src/api/UpnpLog.cpp: In member function ‘int UpnpLog::InitLog()’:
/home/runner/work/pupnp/pupnp/upnp/src/api/UpnpLog.cpp:131:26: error: ‘nullptr’ was not declared in this scope
                 setLogFp(nullptr);
                          ^
/home/runner/work/pupnp/pupnp/upnp/src/api/UpnpLog.cpp: In member function ‘void UpnpLog::Printf(Upnp_LogLevel, Dbg_Module, const char*, int, const char*, __va_list_tag*)’:
/home/runner/work/pupnp/pupnp/upnp/src/api/UpnpLog.cpp:183:34: error: ‘nullptr’ was not declared in this scope
                 size = vsnprintf(nullptr, 0, fmtStr, sizeCopy) + 1;
                                  ^
make[2]: *** [upnp/CMakeFiles/upnp_static.dir/src/api/UpnpLog.cpp.o] Error 1
upnp/CMakeFiles/upnp_static.dir/build.make:187: recipe for target 'upnp/CMakeFiles/upnp_static.dir/src/api/UpnpLog.cpp.o' failed
CMakeFiles/Makefile2:403: recipe for target 'upnp/CMakeFiles/upnp_static.dir/all' failed
make[1]: *** [upnp/CMakeFiles/upnp_static.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2
whyman commented 2 years ago

Which version of C++ is project using? nullptr is available from C++11.

mrjimenez commented 2 years ago

Ubuntu 16.04 build is cmake based. Could it be that its default compiler option is not -std=c++11? Maybe we should include a line in the scripts to print the options beeing used, compiler version, etc.

Vollstrecker commented 2 years ago

If C++11 is needed, we can tell cmake to check and take care of that. I just need to know what to turn off or on when found or not.

mrjimenez commented 2 years ago

C++11 is a more than resonable requirement. I would put this always on.

whyman commented 2 years ago

Commit added to require C++11

Vollstrecker commented 2 years ago

You did it 40 minutes before I arrived home.