diff options
author | Marcus Comstedt <marcus@mc.pp.se> | 2017-02-26 13:07:03 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2017-02-26 14:56:56 +0100 |
commit | de23c992a48b5f9f145a7c26a62f10cd5b87b218 (patch) | |
tree | ab34ed2fbb7a10c4ef88b5c0df5ee6cf794b45a4 /instance.c | |
parent | 066fbafdc3ba734a73b5f7fcfa1dbae67ddebf8a (diff) | |
download | libsigrokdecode-de23c992a48b5f9f145a7c26a62f10cd5b87b218.tar.gz libsigrokdecode-de23c992a48b5f9f145a7c26a62f10cd5b87b218.zip |
Return SRD_ERR_ARG from srd_inst_decode if samplenums are wrong
This validates the requirements that
* abs_start_samplenum continues where the previous decode ended
* abs_end_samplenum is not lower than abs_start_samplenum
Failure to meet these requirements will make v3 decoders crash.
Diffstat (limited to 'instance.c')
-rw-r--r-- | instance.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1010,6 +1010,12 @@ SRD_PRIV int srd_inst_decode(struct srd_decoder_inst *di, return SRD_ERR_ARG; } + if (abs_start_samplenum != di->abs_cur_samplenum || + abs_end_samplenum < abs_start_samplenum) { + srd_dbg("incorrect sample numbers"); + return SRD_ERR_ARG; + } + di->data_unitsize = unitsize; srd_dbg("Decoding: abs start sample %" PRIu64 ", abs end sample %" @@ -1042,6 +1048,7 @@ SRD_PRIV int srd_inst_decode(struct srd_decoder_inst *di, di->inst_id); return SRD_ERR_PYTHON; } + di->abs_cur_samplenum = abs_end_samplenum; Py_DecRef(py_res); } else { /* If this is the first call, start the worker thread. */ |