File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -869,7 +869,7 @@ SRD_API int srd_decoder_load(const char *module_name)
869
869
/**
870
870
* Return a protocol decoder's docstring.
871
871
*
872
- * @param dec The loaded protocol decoder.
872
+ * @param dec The loaded protocol decoder. Must not be NULL.
873
873
*
874
874
* @return A newly allocated buffer containing the protocol decoder's
875
875
* documentation. The caller is responsible for free'ing the buffer.
@@ -885,7 +885,7 @@ SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec)
885
885
if (!srd_check_init ())
886
886
return NULL ;
887
887
888
- if (!dec )
888
+ if (!dec || ! dec -> py_mod )
889
889
return NULL ;
890
890
891
891
gstate = PyGILState_Ensure ();
Original file line number Diff line number Diff line change @@ -404,11 +404,19 @@ END_TEST
404
404
* Check whether srd_decoder_doc_get() fails with NULL as argument.
405
405
* If it returns a value != NULL (or segfaults) this test will fail.
406
406
* See also: http://sigrok.org/bugzilla/show_bug.cgi?id=179
407
+ * Check whether srd_decoder_doc_get() fails with dec->py_mod == NULL.
408
+ * If it returns a value != NULL (or segfaults) this test will fail.
409
+ * See also: http://sigrok.org/bugzilla/show_bug.cgi?id=180
407
410
*/
408
411
START_TEST (test_doc_get_null )
409
412
{
413
+ struct srd_decoder dec ;
414
+
415
+ dec .py_mod = NULL ;
416
+
410
417
srd_init (DECODERS_TESTDIR );
411
418
fail_unless (srd_decoder_doc_get (NULL ) == NULL );
419
+ fail_unless (srd_decoder_doc_get (& dec ) == NULL );
412
420
srd_exit ();
413
421
}
414
422
END_TEST
You can’t perform that action at this time.
0 commit comments