$OpenBSD: patch-stk500v2_c,v 1.4 2010/06/27 20:39:33 ckuethe Exp $ --- stk500v2.c.orig Tue Jan 19 03:39:11 2010 +++ stk500v2.c Sat Jun 26 15:41:53 2010 @@ -353,6 +353,7 @@ static void stk500v2_jtagmkII_setup(PROGRAMMER * pgm) static void stk500v2_teardown(PROGRAMMER * pgm) { free(pgm->cookie); + pgm->cookie = NULL; } static void stk500v2_jtagmkII_teardown(PROGRAMMER * pgm) @@ -364,6 +365,7 @@ static void stk500v2_jtagmkII_teardown(PROGRAMMER * pg jtagmkII_teardown(pgm); free(mycookie); + pgm->cookie = NULL; } @@ -1169,12 +1171,14 @@ static int stk500hv_initialize(PROGRAMMER * pgm, AVRPA if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) { fprintf(stderr, "%s: stk500pp_initialize(): Out of memory\n", progname); + PDATA(pgm)->eeprom_pagecache = NULL; return -1; } if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) { fprintf(stderr, "%s: stk500pp_initialize(): Out of memory\n", progname); free(PDATA(pgm)->flash_pagecache); + PDATA(pgm)->flash_pagecache = NULL; return -1; } PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;