Skip to content

Fixed two memory leaks#1120

Merged
jdumas merged 2 commits intolibigl:devfrom
robertguetzkow:dev
Apr 20, 2019
Merged

Fixed two memory leaks#1120
jdumas merged 2 commits intolibigl:devfrom
robertguetzkow:dev

Conversation

@robertguetzkow
Copy link
Copy Markdown
Contributor

As mentioned in #919 the ply.h implementation has several code quality issues. The suggested changes fix two memory leaks. One is caused by a missing free, another from improper handling when realloc fails. Additionally UB has been identified, because a pointer to a local variable is returned.

Check all that apply (change to [x])

  • All changes meet libigl style-guidelines.
  • Adds new .cpp file.
  • Adds corresponding unit test.
  • Adds corresponding python binding.
  • This is a minor change.

One pointer to allocated memory wasn't freed and realloc didn't have proper error handling. Additionally UB has been identified, because a pointer to a local variable is returned.
@robertguetzkow
Copy link
Copy Markdown
Contributor Author

From what I've seen the implementation needs a major overhaul or a complete replacement. There are also string processing operations that don't look safe.

@jdumas
Copy link
Copy Markdown
Collaborator

jdumas commented Mar 21, 2019

As discussed in the thread ideally we should replace it by another library entirely, e.g. tinyply. I believe dropping the file in include/igl/ and making it safe for header-only inclusion (e.g. cleanup the using namespace std; in the cpp) is the way to go.

@robertguetzkow
Copy link
Copy Markdown
Contributor Author

robertguetzkow commented Mar 21, 2019

@jdumas that would be the best solution. I just thought fixing the bugs until we have a replacement would help a bit.

@jdumas
Copy link
Copy Markdown
Collaborator

jdumas commented Mar 21, 2019

I mean if you want to give it a shot at integrating tinyply or rply, feel free to do so!

@jdumas jdumas merged commit 7677e66 into libigl:dev Apr 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants