From e195c025c303e361d0cc5a207f9c9443fb8deced Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Mon, 18 Nov 2013 01:21:16 +0100 Subject: Check library initialization before handling decoders --- decoder.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'decoder.c') diff --git a/decoder.c b/decoder.c index ef7e15d..c379d4b 100644 --- a/decoder.c +++ b/decoder.c @@ -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; -- cgit v1.2.3-70-g09d2