Patchwork [4/7] qemu-io: fix a memory leak

login
register
mail settings
Submitter Blue Swirl
Date Jan. 8, 2011, 6:24 p.m.
Message ID <AANLkTim=TpYeWkYaCJEY6+HMno3Vj-F4d071nu4HSo6H@mail.gmail.com>
Download mbox | patch
Permalink /patch/77974/
State New
Headers show

Comments

Blue Swirl - Jan. 8, 2011, 6:24 p.m.
Fix a memory leak, reported by cppcheck:
[/src/qemu/qemu-io.c:1135]: (error) Memory leak: ctx

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 qemu-io.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Patch

diff --git a/qemu-io.c b/qemu-io.c
index 65dee13..5b24c5e 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1131,8 +1131,10 @@  aio_read_f(int argc, char **argv)
 		case 'P':
 			ctx->Pflag = 1;
 			ctx->pattern = parse_pattern(optarg);
-			if (ctx->pattern < 0)
+			if (ctx->pattern < 0) {
+                                free(ctx);
 				return 0;
+                        }
 			break;
 		case 'q':
 			ctx->qflag = 1;