From 4453d5d4833661d4b49ea518d07c0e4c73b40dc3 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Tue, 21 Jul 2015 09:26:27 -0400 Subject: [PATCH] Fix several potential memory leaks in PlyFile.cpp --- Src/PlyFile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Src/PlyFile.cpp b/Src/PlyFile.cpp index 3ce7a95..7635b87 100644 --- a/Src/PlyFile.cpp +++ b/Src/PlyFile.cpp @@ -259,6 +259,7 @@ PlyFile *ply_open_for_writing( /* open the file for writing */ fp = fopen (name, "wb"); + free(name); if (fp == NULL) { return (NULL); } @@ -878,6 +879,7 @@ Open a polygon file for reading. /* open the file for reading */ fp = fopen (name, "rb"); + free(name); if (fp == NULL) return (NULL); @@ -892,7 +894,6 @@ Open a polygon file for reading. /* return a pointer to the file's information */ - free(name); return (plyfile); } @@ -1873,6 +1874,7 @@ Read an element from a binary file. /* read in a line */ result = fgets (str, BIG_STRING, fp); if (result == NULL) { + free(words); *nwords = 0; *orig_line = NULL; return (NULL);