为什么 g_object_set 抛出异常(vcruntime140.dll)?
Why g_object_set throws an exception(vcruntime140.dll)?
#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";
}
在g_object_set(source, "location", "rtsp://192.168.10.24:554");
之后发生异常:在ConsoleApplication1.exe中的0x00007FFC26E9193C(vcruntime140.dll)抛出异常:0xC0000005:访问冲突读取位置0x0000000000008000。
函数 gst_element_factory_make
returns 不是 NULL。为什么抛出这个异常?
根据找到的文档 here,问题是 g_object_set
是一个可变参数函数,需要您输入标记参数(在本例中,NULL
).
g_object_set(source, "location", "rtsp://192.168.10.24:554", NULL);
不放置NULL
意味着可变参数函数不知道何时到达最后一个参数,因此正在处理导致分段错误的无效数据。
#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";
}
在g_object_set(source, "location", "rtsp://192.168.10.24:554");
之后发生异常:在ConsoleApplication1.exe中的0x00007FFC26E9193C(vcruntime140.dll)抛出异常:0xC0000005:访问冲突读取位置0x0000000000008000。
函数 gst_element_factory_make
returns 不是 NULL。为什么抛出这个异常?
根据找到的文档 here,问题是 g_object_set
是一个可变参数函数,需要您输入标记参数(在本例中,NULL
).
g_object_set(source, "location", "rtsp://192.168.10.24:554", NULL);
不放置NULL
意味着可变参数函数不知道何时到达最后一个参数,因此正在处理导致分段错误的无效数据。