From 1cb821d6594935fbcbd9230fee107836c3dbd023 Mon Sep 17 00:00:00 2001 From: Stefan Kremser Date: Mon, 17 Jun 2019 16:23:05 +0200 Subject: [PATCH] Fixed deallocation bug --- esp8266_deauther/Attack.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/esp8266_deauther/Attack.cpp b/esp8266_deauther/Attack.cpp index 0833018..01af1ab 100644 --- a/esp8266_deauther/Attack.cpp +++ b/esp8266_deauther/Attack.cpp @@ -366,15 +366,16 @@ bool Attack::sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2) { tmpPacket[37] = ssidLen; // update SSID length byte memcpy(&tmpPacket[38 + ssidLen], &beaconPacket[70], wpa2 ? 39 : 13); // copy second half of packet into buffer - if (sendPacket(tmpPacket, tmpPacketSize, ch, 1)) { + bool success = sendPacket(tmpPacket, tmpPacketSize, ch, 1); + + if (success) { beacon.time = currentTime; beacon.packetCounter++; - delete tmpPacket; // free memory of allocated buffer - return true; - } else { - delete tmpPacket; // free memory of allocated buffer - return false; } + + delete[] tmpPacket; // free memory of allocated buffer + + return success; // ===== }