@@ -82,6 +82,11 @@ struct state_vidcap_spout {
8282 int frames;
8383};
8484
85+ /* *
86+ * @param probe do not abort if unable to create Spout instance
87+ * @returns shared_ptr with valid Spout instance, unless probe=true
88+ * in which case empty shared_ptr may be returned if error
89+ */
8590static shared_ptr<SPOUTLIBRARY>
8691get_spout (bool probe)
8792{
@@ -126,6 +131,23 @@ static void usage()
126131 }
127132}
128133
134+ static void
135+ check_lib ()
136+ {
137+ static shared_ptr<SPOUTLIBRARY> spout = get_spout (false );
138+ constexpr char name[] = " test_sender" ;
139+ spout->SetSenderName (name);
140+ if (strcmp (spout->GetSenderName (), name) != 0 ) {
141+ // in case of the GH-487 problem, it actually doesn't reach
142+ // here but segfaults on the returned name from the library
143+ // because (const char *) 0x1 is returned
144+ fprintf (stderr, " Unexpected sender name: %s (exp: %s)\n " ,
145+ spout->GetSenderName (), name);
146+ abort ();
147+ }
148+ printf (" SpoutLibrary vtable doesn't seem to be corrupted.\n " );
149+ }
150+
129151static int vidcap_spout_init (struct vidcap_params *params, void **state)
130152{
131153 if ((vidcap_params_get_flags (params) & VIDCAP_FLAG_AUDIO_ANY) != 0U ) {
@@ -147,6 +169,10 @@ static int vidcap_spout_init(struct vidcap_params *params, void **state)
147169 usage ();
148170 ret = VIDCAP_INIT_NOERR;
149171 break ;
172+ } else if (strcmp (item, " check_lib" ) == 0 ) {
173+ check_lib ();
174+ ret = VIDCAP_INIT_NOERR;
175+ break ;
150176 } else if (strstr (item, " name=" ) == item) {
151177 char *name = item + strlen (" name=" );
152178 if (strstr (name, " urlencoded=" ) == name) {
0 commit comments