Commit a5c4a9a7 authored by Sean McBride's avatar Sean McBride

Fixed memory leaks and malloc(0)

Fixed some minor leaks in error branches.
Prevent a malloc(0) from occurring by bailing beforehand.

Change-Id: I85cdc7d12a2598d477f3b956b86d445273698ed6
parent 14c4790c
......@@ -722,7 +722,11 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
if (equal_strings (words[0], "format")) {
if (nwords != 3)
{
free (plyfile);
free (words);
return (NULL);
}
if (equal_strings (words[1], "ascii"))
plyfile->file_type = PLY_ASCII;
else if (equal_strings (words[1], "binary_big_endian"))
......@@ -731,6 +735,7 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
plyfile->file_type = PLY_BINARY_LE;
else
{
free (plyfile);
free (words);
return (NULL);
}
......@@ -747,6 +752,7 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
else if (equal_strings (words[0], "end_header"))
{
free (words);
words = NULL;
break;
}
......@@ -756,6 +762,12 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
words = get_words (plyfile->fp, &nwords, &orig_line);
}
if (plyfile->nelems == 0)
{
free (plyfile);
free (words);
return (NULL);
}
/* create tags for each property of each element, to be used */
/* later to say whether or not to store each property for the user */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment