nvdsvideotemplate (gst_nvdsvideotemplate_get_property) gets the custom library string properties by calling QueryProperties (returns a char* which is a string pointer rather than a pointer to an (unsigned) integer).
Then at NVIDIA/DeepStream - gstnvdsvideotemplate.cpp:625 it deallocates it: delete str; when it should be delete[] str;. That's Undefined Behavior, although it's known to work.
While we're at it, I think DSCustomLibraryBase::QueryProperties() (or from parent interface) should contain some doc or comment mentioning:
- The returned string is deallocated by videotemplate
- The deallocator used (in order to create the string with the appropriate allocator)
Initially I was returning the contents of a custom library class member, and that triggered gst-inspect-1.0 to segfault. With new[] or strdup (I chose the former) it no longer segfaults, but it's still incorrect.
Steps/Code to reproduce bug
The issue has no observable output (without using debug/profile tools), so using the first (wrong) variant that I had:
- Create a minimal custom library with e.g.:
const char CustomLib::m_member[] = "dummy\n";
char* CustomLib::QueryProperties() {
return const_cast<char*> m_member; // !nullptr
}
make
NVDS_CUSTOMLIB="path/to/libcustomlib.so" gst-inspect-1.0 nvdsvideotemplate
Expected behavior
The output should contain the string, instead of segfaulting.
Environment details (please complete the following information):
N/A. I used a NVidia DS container.
Additional context
N/A
Might also apply to others (audiotemplate?).
By submitting this issue, you agree to follow our code of conduct and our contribution guidelines.
nvdsvideotemplate (
gst_nvdsvideotemplate_get_property) gets the custom library string properties by callingQueryProperties(returns achar*which is a string pointer rather than a pointer to an (unsigned) integer).Then at NVIDIA/DeepStream - gstnvdsvideotemplate.cpp:625 it deallocates it:
delete str;when it should bedelete[] str;. That's Undefined Behavior, although it's known to work.While we're at it, I think
DSCustomLibraryBase::QueryProperties()(or from parent interface) should contain some doc or comment mentioning:Initially I was returning the contents of a custom library class member, and that triggered
gst-inspect-1.0to segfault. Withnew[]orstrdup(I chose the former) it no longer segfaults, but it's still incorrect.Steps/Code to reproduce bug
The issue has no observable output (without using debug/profile tools), so using the first (wrong) variant that I had:
makeNVDS_CUSTOMLIB="path/to/libcustomlib.so" gst-inspect-1.0 nvdsvideotemplateExpected behavior
The output should contain the string, instead of segfaulting.
Environment details (please complete the following information):
N/A. I used a NVidia DS container.
Additional context
N/A
Might also apply to others (audiotemplate?).
By submitting this issue, you agree to follow our code of conduct and our contribution guidelines.