[ovs-dev] [PATCH] ofp-parse: Fix memory leak on error path in parse_ofp_group_mod_file().

Ben Pfaff blp at ovn.org
Fri May 26 23:25:18 UTC 2017


Found by Coverity.

Reported-by: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762655&defectInstanceId=4305334&mergedDefectId=180394
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/ofp-parse.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index c8cac5b4765c..3b12a90dbd53 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1861,7 +1861,9 @@ parse_ofp_group_mod_file(const char *file_name, int command,
                 fclose(stream);
             }
 
-            return xasprintf("%s:%d: %s", file_name, line_number, error);
+            char *ret = xasprintf("%s:%d: %s", file_name, line_number, error);
+            free(error);
+            return ret;
         }
         *usable_protocols &= usable;
         *n_gms += 1;
-- 
2.10.2



More information about the dev mailing list