From d95b876d19a0bddf7f23d686833667d23a100b2b Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Wed, 16 May 2007 20:15:13 +0000
Subject: [PATCH] In avr_read() and avr_write(), only use the paged_load and
 paged_write backend functions iff the memory area in question has a page_size
 != 0.

This is supposed to fix bug #19234: avrdude-5.3.1 segfaults when
stk500v1 tries to program an ATtiny15


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@739 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog | 8 ++++++++
 avr.c     | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 035aac29..fadf932d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-16 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	* avr.c (avr_read, avr_write): only use the paged_load and
+	paged_write backend functions iff the memory area in question has
+	a page_size != 0.
+	This is supposed to fix bug #19234: avrdude-5.3.1 segfaults when
+	stk500v1 tries to program an ATtiny15
+
 2007-05-15 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	* avr910.c: Fall back to avr_{read,write}_byte_default().  Fixes
diff --git a/avr.c b/avr.c
index b0d24133..45ed124c 100644
--- a/avr.c
+++ b/avr.c
@@ -172,7 +172,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
   memset(buf, 0xff, size);
 
   if ((strcmp(mem->desc, "flash")==0) || (strcmp(mem->desc, "eeprom")==0)) {
-    if (pgm->paged_load != NULL) {
+    if (pgm->paged_load != NULL && mem->page_size != 0) {
       /*
        * the programmer supports a paged mode read, perhaps more
        * efficiently than we can read it directly, so use its routine
@@ -569,7 +569,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
   }
 
   if ((strcmp(m->desc, "flash")==0) || (strcmp(m->desc, "eeprom")==0)) {
-    if (pgm->paged_write != NULL) {
+    if (pgm->paged_write != NULL && m->page_size != 0) {
       /*
        * the programmer supports a paged mode write, perhaps more
        * efficiently than we can read it directly, so use its routine