Skip to contentSkip to conversation

lib/strutil: fix parse_switch resource leak [coverity scan]

PATCH In review Andreas Henriksson 2 participants 3 messages Aug 25, 2015 – Aug 31, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/strutil: fix parse_switch resource leak [coverity scan]

---
 lib/strutils.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/strutils.c +5 -2
index b033f75..30dc090 100644
@@ -198,10 +198,13 @@ int parse_switch(const char *arg, const char *errmesg, ...)
 		if (!b)
 			break;
 
-		if (strcmp(arg, a) == 0)
+		if (strcmp(arg, a) == 0) {
+			va_end(ap);
 			return 1;
-		else if (strcmp(arg, b) == 0)
+		} else if (strcmp(arg, b) == 0) {
+			va_end(ap);
 			return 0;
+		}
 	} while (1);
 	va_end(ap);
 
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/2 lsblk: fix resource leak [coverity scan]

---
 misc-utils/lsblk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
misc-utils/lsblk.c +3 -1
index 4cfeef8..d1bb13a 100644
@@ -762,8 +762,10 @@ static char *get_subsystems(struct blkdev_cxt *cxt)
 		size_t sz;
 
 		/* don't create "block:scsi:scsi", but "block:scsi" */
-		if (len && strcmp(res + last, sub) == 0)
+		if (len && strcmp(res + last, sub) == 0) {
+			free(sub);
 			continue;
+		}
 
 		sz = strlen(sub);
 		res = xrealloc(res, len + sz + 2);
Signature · 1 line
2.1.4