ricortiz/SCCD — pull request #1 by ivn (2014-07-11 07:42:47+00:00)
Title: fixed double free bug caused by two fclose() on fd

File descriptor of .ply file already closed in ply_close(). Second fclose() causes "double free or corruption" error. I removed this needless fclose().

Here is backtrace from gdb to see the problem:

Reading symbols from ./build/main...(no debugging symbols found)...done.
(gdb) run
Starting program: /home/ivan/tmp/SCCD/sample/build/main
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
*** Error in `/home/ivan/tmp/SCCD/sample/build/main': double free or corruption (!prev): 0x000000000063e010 ***

Program received signal SIGABRT, Aborted.
0x00007ffff701bf79 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff701bf79 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff701f388 in __GI_abort () at abort.c:89
#2 0x00007ffff70591d4 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff7167a10 "*** Error in `%s': %s: 0x%s ***\n")
at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff70654ae in malloc_printerr (ptr=, str=0x7ffff7167af8 "double free or corruption (!prev)", action=1) at malloc.c:4996
#4 _int_free (av=, p=, have_lock=0) at malloc.c:3840
#5 0x00007ffff7053925 in _IO_new_fclose (fp=0x63e010) at iofclose.c:85
#6 0x000000000041aae9 in BuildSession(char*, unsigned int, float, unsigned int&, vec3*&, std::vector, std::allocator > >&, std::vector >&) ()
#7 0x0000000000415737 in main ()
(gdb)