]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/asix-sigma/protocol.c
asix-sigma: fix buffer length check in register write helper
[libsigrok.git] / src / hardware / asix-sigma / protocol.c
index 49163da990155d924ef5aff178158877ee7f0407..d2670b4c3a974e503330f9a1564fd2b1737772e1 100644 (file)
@@ -105,9 +105,9 @@ SR_PRIV int sigma_write_register(uint8_t reg, uint8_t *data, size_t len,
        uint8_t buf[80];
        int idx = 0;
 
-       if ((len + 2) > sizeof(buf)) {
+       if ((2 * len + 2) > sizeof(buf)) {
                sr_err("Attempted to write %zu bytes, but buffer is too small.",
-                      len + 2);
+                      len);
                return SR_ERR_BUG;
        }