segmentation fault length fix
authorbruno_dalbo <bruno.dalbo@hp.com>
Mon, 17 Aug 2015 17:54:19 +0000 (14:54 -0300)
committerbruno_dalbo <bruno.dalbo@hp.com>
Mon, 17 Aug 2015 17:54:19 +0000 (14:54 -0300)
gdbserver/gdb-server.c

index 0ddebb06f8a0bb21cfdaa8569ccf8b6f364247a6..d902eab7ea8658af2cc0f25f199630a8919d2a77 100644 (file)
@@ -654,10 +654,12 @@ static int flash_go(stlink_t *sl) {
             stlink_calculate_pagesize(sl, page);
 
             DLOG("flash_do: page %08x\n", page);
-
+            unsigned send = length > FLASH_PAGE ? FLASH_PAGE : length;
             if(stlink_write_flash(sl, page, fb->data + (page - fb->addr),
-                        length > FLASH_PAGE ? FLASH_PAGE : length) < 0)
+                        send) < 0)
                 goto error;
+            length -= send;
+            
         }
     }