From c9e020da7440e1e9c022840eef23a2caa1a4b910 Mon Sep 17 00:00:00 2001 From: Huntereb Date: Mon, 9 Dec 2019 19:46:02 -0500 Subject: [PATCH] Clear buffers after we're done with them in BufferData() --- source/install/usb_nsp.cpp | 11 ++++++----- source/install/usb_xci.cpp | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/source/install/usb_nsp.cpp b/source/install/usb_nsp.cpp index e383c11..c3407c7 100755 --- a/source/install/usb_nsp.cpp +++ b/source/install/usb_nsp.cpp @@ -8,8 +8,8 @@ #include "data/byte_buffer.hpp" #include "data/buffered_placeholder_writer.hpp" #include "util/usb_util.hpp" -#include "error.hpp" -#include "debug.h" +#include "util/error.hpp" +#include "util/debug.h" #include "sdInstall.hpp" #include "util/util.hpp" #include "util/usb_comms_awoo.h" @@ -156,8 +156,9 @@ namespace tin::install::nsp { LOG_DEBUG("buffering 0x%lx-0x%lx", offset, offset + size); tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(m_nspName, offset, size); - u8* ourBuffer = (u8*)memalign(0x1000, header.dataSize); - if (tin::util::USBRead(ourBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed"); - memcpy(buf, ourBuffer, header.dataSize); + u8* tempBuffer = (u8*)memalign(0x1000, header.dataSize); + if (tin::util::USBRead(tempBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed"); + memcpy(buf, tempBuffer, header.dataSize); + free(tempBuffer); } } \ No newline at end of file diff --git a/source/install/usb_xci.cpp b/source/install/usb_xci.cpp index ca1e5da..5ca84bb 100755 --- a/source/install/usb_xci.cpp +++ b/source/install/usb_xci.cpp @@ -8,8 +8,8 @@ #include "data/byte_buffer.hpp" #include "data/buffered_placeholder_writer.hpp" #include "util/usb_util.hpp" -#include "error.hpp" -#include "debug.h" +#include "util/error.hpp" +#include "util/debug.h" #include "sdInstall.hpp" #include "util/util.hpp" #include "util/usb_comms_awoo.h" @@ -156,8 +156,9 @@ namespace tin::install::xci { LOG_DEBUG("buffering 0x%lx-0x%lx", offset, offset + size); tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(m_xciName, offset, size); - u8* ourBuffer = (u8*)memalign(0x1000, header.dataSize); - if (tin::util::USBRead(ourBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed"); - memcpy(buf, ourBuffer, header.dataSize); + u8* tempBuffer = (u8*)memalign(0x1000, header.dataSize); + if (tin::util::USBRead(tempBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed"); + memcpy(buf, tempBuffer, header.dataSize); + free(tempBuffer); } } \ No newline at end of file