marcus905 / libnfc

Automatically exported from code.google.com/p/libnfc
GNU Lesser General Public License v3.0
0 stars 0 forks source link

redundant free() in pn532_uart_close() #242

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
pn532_uart.c:155 invokes uart_close() passing DRIVER_DATA(pnd)->port as the 
serial port.

uart_close() using uart_posix.c invokes uart_close_ext() which invokes
free() on the passed serial port.

Back in the caller, pn532_uart.c:163 then invokes free() on the same port, 
resulting in a memory corruption.

Reproducible and diagnosed with the following command on Fedora 16 with an 
Adafruit PN532 breakout board attached to usb0: 

env LIBNFC_INTRUSIVE_SCAN=yes valgrind /usr/local/libnfc/bin/nfc-scan-device

The error appears to have been introduced in 

  commit cc03f84636c03d6a06d47dd3ca84fe2ace04fea8
  Author: Philippe Teuwen <yobibe@gmail.com>
  Date:   Sun Mar 10 00:20:52 2013 +0100

    New connstring_decode() fix cppcheck warning "Non reentrant function 'strtok' called"

Original issue reported on code.google.com by pabi...@gmail.com on 15 Mar 2013 at 7:41

GoogleCodeExporter commented 9 years ago
Thanks for this detailed report!

Original comment by yob...@gmail.com on 16 Mar 2013 at 11:27

GoogleCodeExporter commented 9 years ago
This issue was closed by revision ca7477e935df.

Original comment by yob...@gmail.com on 16 Mar 2013 at 11:28