Skip to content

Commit

Permalink
examples/c++/uart.cpp: Add fix for potential memory leak
Browse files Browse the repository at this point in the history
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
  • Loading branch information
adelindobre authored and Propanu committed Mar 6, 2019
1 parent 1278089 commit 5d6f0ef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/c++/uart.cpp
Expand Up @@ -61,9 +61,10 @@ main(void)
// If you have a valid platform configuration use numbers to represent uart
// device. If not use raw mode where std::string is taken as a constructor
// parameter
mraa::Uart* uart;
mraa::Uart* uart, *temp;
try {
uart = new mraa::Uart(UART_PORT);
temp = uart;
} catch (std::exception& e) {
std::cerr << e.what() << ", likely invalid platform config" << std::endl;
}
Expand Down Expand Up @@ -96,6 +97,7 @@ main(void)
//! [Interesting]

delete uart;
delete temp;

return EXIT_SUCCESS;
}

0 comments on commit 5d6f0ef

Please sign in to comment.