From dfb2335b072493170e1e482a7f7de105158f615b Mon Sep 17 00:00:00 2001
From: rliebscher <rliebscher@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Sat, 17 Dec 2011 17:00:51 +0000
Subject: [PATCH] Fixed another memory leak, when define an operation more than
 once; also fixed the conf.in-file (This might need to be reworked when avr
 parts can have parents.)

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1023 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 avrdude.conf.in | 10 ----------
 config_gram.y   | 12 ++++++++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/avrdude.conf.in b/avrdude.conf.in
index 14b78d9f..becff92f 100644
--- a/avrdude.conf.in
+++ b/avrdude.conf.in
@@ -6477,16 +6477,6 @@ part
 			  "  0   0   0   0      0  a2  a1  a0",
 			  "  i   i   i   i      i   i   i   i";
 
-	writepage	= "  1   1   0   0      0   0   1   0",
-			  "  0   0   x   x      x   x   x  a8",
-			  " a7  a6  a5  a4     a3   0   0   0",
-			  "  x   x   x   x      x   x   x   x";
-
-	loadpage_lo	= "  1   1   0   0      0   0   0   1",
-			  "  0   0   0   0      0   0   0   0",
-			  "  0   0   0   0      0  a2  a1  a0",
-			  "  i   i   i   i      i   i   i   i";
-
 	writepage	= "  1   1   0   0      0   0   1   0",
 			  "  0   0   x   x      x a10  a9  a8",
 			  " a7  a6  a5  a4     a3   0   0   0",
diff --git a/config_gram.y b/config_gram.y
index 61028ef6..df6619c8 100644
--- a/config_gram.y
+++ b/config_gram.y
@@ -1153,6 +1153,12 @@ part_parm :
       opnum = which_opcode($1);
       op = avr_new_opcode();
       parse_cmdbits(op);
+      if (current_part->op[opnum] != NULL) {
+        fprintf(stderr,
+              "%s: warning at %s:%d: operation redefined\n",
+              progname, infile, lineno);
+        free(current_part->op[opnum]);
+      }
       current_part->op[opnum] = op;
 
       free_token($1);
@@ -1274,6 +1280,12 @@ mem_spec :
       opnum = which_opcode($1);
       op = avr_new_opcode();
       parse_cmdbits(op);
+      if (current_mem->op[opnum] != NULL) {
+        fprintf(stderr,
+              "%s: warning at %s:%d: operation redefined\n",
+              progname, infile, lineno);
+        free(current_mem->op[opnum]);
+      }
       current_mem->op[opnum] = op;
 
       free_token($1);