cpp-io2d / P0267_RefImpl

Reference Implementations of P0267, the proposed 2D graphics API for ISO C++
Other
313 stars 114 forks source link

Use after free error #120

Open Xazax-hun opened 4 years ago

Xazax-hun commented 4 years ago

I am working on some new compiler warnings and stumbled upon the following warning: https://github.com/cpp-io2d/P0267_RefImpl/blob/add3c9792dcd3f08c497ae3adafb2a3b5b5fc338/P0267_RefImpl/P0267_RefImpl/cairo/xlib/xio2d_cairo_xlib_output_surfaces.h#L329

/home/tgahor/data/projects/P0267_RefImpl/P0267_RefImpl/P0267_RefImpl/cairo/xlib/xio2d_cairo_xlib_output_surfaces.h:329:19: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling]
                                                                auto es = clientMsgStr.str().c_str();
                                                                          ^~~~~~~~~~~~~~~~~~

This looks like a true positive as the pointer returned by c_str() will dangle after the end of the full expression.