diff options
author | Bert Vermeulen <bert@biot.com> | 2013-11-18 01:21:16 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2013-11-18 01:21:16 +0100 |
commit | e195c025c303e361d0cc5a207f9c9443fb8deced (patch) | |
tree | 86e05c7d93dc5b77c1510519659763929cc5eee5 /decoder.c | |
parent | 909fbf4181ab401a371265567505ffa1403f73d6 (diff) | |
download | libsigrokdecode-e195c025c303e361d0cc5a207f9c9443fb8deced.tar.gz libsigrokdecode-e195c025c303e361d0cc5a207f9c9443fb8deced.zip |
Check library initialization before handling decoders
Diffstat (limited to 'decoder.c')
-rw-r--r-- | decoder.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -253,6 +253,9 @@ SRD_API int srd_decoder_load(const char *module_name) struct srd_probe *p; GSList *l; + if (!srd_check_init()) + return SRD_ERR; + if (!module_name) return SRD_ERR_ARG; @@ -446,6 +449,12 @@ SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec) PyObject *py_str; char *doc; + if (!srd_check_init()) + return NULL; + + if (!dec) + return NULL; + if (!PyObject_HasAttrString(dec->py_mod, "__doc__")) return NULL; @@ -495,6 +504,12 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec) struct srd_session *sess; GSList *l; + if (!srd_check_init()) + return SRD_ERR; + + if (!dec) + return SRD_ERR_ARG; + srd_dbg("Unloading protocol decoder '%s'.", dec->name); /* @@ -548,6 +563,9 @@ SRD_API int srd_decoder_load_all(void) GError *error; const gchar *direntry; + if (!srd_check_init()) + return SRD_ERR; + if (!(dir = g_dir_open(DECODERS_DIR, 0, &error))) { srd_err("Unable to open %s for reading.", DECODERS_DIR); return SRD_ERR_DECODERS_DIR; |