Why g_object_set throws an exception(vcruntime140.dll)?

-2
#pragma comment(lib, "gstreamer-1.0.lib")
#pragma comment(lib, "gobject-2.0.lib")


#include <iostream>
#include <gst/gst.h>


int main( int argc, char *argv[] )
{
    gst_init( &argc, &argv );
    GstElement *source = nullptr;
    source = gst_element_factory_make("rtspsrc", "test_src");
    g_object_set(source, "location", "rtsp://192.168.10.24:554");
    std::cout << "End";

}

After g_object_set(source, "location", "rtsp://192.168.10.24:554"); an exception occurs: Exception thrown at 0x00007FFC26E9193C (vcruntime140.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x0000000000008000. Function gst_element_factory_make returns not NULL. Why this exception throws?

c++
visual-studio
gstreamer

1 Answer

1

According to the documentation found here, the issue is that the g_object_set is a variable-argument function that requires you to put in the sentinel argument (in this case, NULL).

g_object_set(source, "location", "rtsp://192.168.10.24:554", NULL);

Not placing NULL means that the variable argument function does not know when the last argument is reached, thus is processing invalid data which causes the segmentation fault.

answered on Stack Overflow Dec 16, 2019 by PaulMcKenzie

User contributions licensed under CC BY-SA 3.0