Clip flash read request to maximum flash size
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Sun, 18 Dec 2011 18:03:58 +0000 (19:03 +0100)
committerUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Sun, 18 Dec 2011 18:03:58 +0000 (19:03 +0100)
src/stlink-common.c

index 8493c4ce2858af0e4fbeadaababeda7e53b016e4..b49e21ab046afeb36e7b27ae605320381ef85215 100644 (file)
@@ -812,6 +812,9 @@ int stlink_fread(stlink_t* sl, const char* path, stm32_addr_t addr, size_t size)
         return -1;
     }
 
+    if (size > sl->flash_size)
+       size = sl->flash_size;
+
     /* do the copy by 1k blocks */
     for (off = 0; off < size; off += 1024) {
         size_t read_size = 1024;