df45990f88c1 — pouya@nohup.io 4 months ago
free memory on parse error
1 files changed, 4 insertions(+), 1 deletions(-)

M drugbank.c
M drugbank.c +4 -1
@@ 40,7 40,10 @@ nextdrug(yxml_t *y, char c) {
 		d.doc[d.doclen] = 0;
 	}
 
-	if((r = yxml_parse(y, c)) < 0) return nil;
+	if((r = yxml_parse(y, c)) < 0) {
+		termdrug(&d);
+		return nil;
+	}
 	switch(r) {
 	case YXML_ELEMEND:
 		if(depth==2 && streq(elem[depth-1], "drug")) {