This is an automated email from Gerrit.

Darius Rad ([email protected]) just uploaded a new patch set to Gerrit, which 
you can find at http://openocd.zylin.com/4550

-- gerrit

commit edd09ed3e7fdd25a272cc0d0208f912ef06789fb
Author: Darius Rad <[email protected]>
Date:   Tue May 22 16:38:57 2018 -0400

    Avoid dereferencing NULL pointer.
    
    If a NULL pointer is passed, don't attempt to index it.  This avoids
    passing the now not-NULL pointer on and eventually segfaulting.
    
    Change-Id: I268e225121aa283d59179bfae407ebf6959d3a4e
    Signed-off-by: Darius Rad <[email protected]>

diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c
index 9a207ef..169b0f0 100644
--- a/src/jtag/drivers/jtag_vpi.c
+++ b/src/jtag/drivers/jtag_vpi.c
@@ -212,15 +212,17 @@ static int jtag_vpi_queue_tdi(uint8_t *bits, int nb_bits, 
int tap_shift)
        int xmit_nb_bits = nb_bits;
        int i = 0;
        int retval;
+       uint8_t *buf;
 
        while (nb_xfer) {
+               buf = (bits == NULL) ? NULL : &xmit_buffer[i];
 
                if (nb_xfer ==  1) {
-                       retval = jtag_vpi_queue_tdi_xfer(&xmit_buffer[i], 
xmit_nb_bits, tap_shift);
+                       retval = jtag_vpi_queue_tdi_xfer(buf, xmit_nb_bits, 
tap_shift);
                        if (retval != ERROR_OK)
                                return retval;
                } else {
-                       retval = jtag_vpi_queue_tdi_xfer(&xmit_buffer[i], 
XFERT_MAX_SIZE * 8, NO_TAP_SHIFT);
+                       retval = jtag_vpi_queue_tdi_xfer(buf, XFERT_MAX_SIZE * 
8, NO_TAP_SHIFT);
                        if (retval != ERROR_OK)
                                return retval;
                        xmit_nb_bits -= XFERT_MAX_SIZE * 8;

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to