summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2013-11-18 00:03:53 +0100
committerBert Vermeulen <bert@biot.com>2013-11-18 00:03:53 +0100
commitca27aa8f9d91d68bfd55fb17fea181a1ba6054a4 (patch)
tree595d3b08a5eca75c7ddd3d1fb96cb3752aa9c43e /session.c
parenta3a2a26d2a93d1fe7a3bb2e8eb732509c8c905e6 (diff)
downloadlibsigrokdecode-ca27aa8f9d91d68bfd55fb17fea181a1ba6054a4.tar.gz
libsigrokdecode-ca27aa8f9d91d68bfd55fb17fea181a1ba6054a4.zip
Better error checking on session metadata
Diffstat (limited to 'session.c')
-rw-r--r--session.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/session.c b/session.c
index 109ede1..7eeab16 100644
--- a/session.c
+++ b/session.c
@@ -170,10 +170,27 @@ SRD_API int srd_session_metadata_set(struct srd_session *sess, int key,
return SRD_ERR_ARG;
}
+ if (!key) {
+ srd_err("Invalid key.");
+ return SRD_ERR_ARG;
+ }
+
+ if (!data) {
+ srd_err("Invalid value.");
+ return SRD_ERR_ARG;
+ }
+
+ /* Hardcoded to samplerate/uint64 for now. */
+
if (key != SRD_CONF_SAMPLERATE) {
srd_err("Unknown config key %d.", key);
return SRD_ERR_ARG;
}
+ if (!g_variant_is_of_type(data, G_VARIANT_TYPE_UINT64)) {
+ srd_err("Invalid value type: expected uint64, got %s",
+ g_variant_get_type_string(data));
+ return SRD_ERR_ARG;
+ }
srd_dbg("Setting session %d samplerate to %"PRIu64".",
sess->session_id, g_variant_get_uint64(data));