Fix #74, memory leak in verifyBlock() (#75)

- Fix #74, memory leak in setBlockVerify()
This commit is contained in:
Rob Tillaart
2024-10-09 09:38:39 +02:00
committed by GitHub
parent 0de303ff95
commit 8cb180d081
6 changed files with 20 additions and 11 deletions
+5 -1
View File
@@ -6,10 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.9.0] - 2024-10-09
- Fix #74, memory leak in setBlockVerify() - kudos to cmichailidis
----
## [1.8.5] - 2024-04-22 ## [1.8.5] - 2024-04-22
- Fix #72, force requestFrom parameters to use int type - Fix #72, force requestFrom parameters to use int type
## [1.8.4] - 2024-04-20 ## [1.8.4] - 2024-04-20
- Fix #70, increase length internal buffer. - Fix #70, increase length internal buffer.
- add compile time flag **EN_AUTO_WRITE_PROTECT** (thanks to microfoundry) - add compile time flag **EN_AUTO_WRITE_PROTECT** (thanks to microfoundry)
+6 -2
View File
@@ -1,7 +1,7 @@
// //
// FILE: I2C_eeprom.cpp // FILE: I2C_eeprom.cpp
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 1.8.5 // VERSION: 1.9.0
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al. // PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
// URL: https://github.com/RobTillaart/I2C_EEPROM // URL: https://github.com/RobTillaart/I2C_EEPROM
@@ -235,7 +235,11 @@ bool I2C_eeprom::setBlockVerify(const uint16_t memoryAddress, const uint8_t valu
if (setBlock(memoryAddress, value, length) != 0) return false; if (setBlock(memoryAddress, value, length) != 0) return false;
uint8_t * data = (uint8_t *) malloc(length); uint8_t * data = (uint8_t *) malloc(length);
if (data == NULL) return false; if (data == NULL) return false;
if (readBlock(memoryAddress, data, length) != length) return false; if (readBlock(memoryAddress, data, length) != length)
{
free(data);
return false;
}
for (uint16_t i = 0; i < length; i++) for (uint16_t i = 0; i < length; i++)
{ {
if (data[i] != value) if (data[i] != value)
+2 -2
View File
@@ -2,7 +2,7 @@
// //
// FILE: I2C_eeprom.h // FILE: I2C_eeprom.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 1.8.5 // VERSION: 1.9.0
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al. // PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
// URL: https://github.com/RobTillaart/I2C_EEPROM // URL: https://github.com/RobTillaart/I2C_EEPROM
@@ -11,7 +11,7 @@
#include "Wire.h" #include "Wire.h"
#define I2C_EEPROM_VERSION (F("1.8.5")) #define I2C_EEPROM_VERSION (F("1.9.0"))
#define I2C_DEVICESIZE_24LC512 65536 #define I2C_DEVICESIZE_24LC512 65536
#define I2C_DEVICESIZE_24LC256 32768 #define I2C_DEVICESIZE_24LC256 32768
+5 -4
View File
@@ -26,7 +26,7 @@ Not supported is the identification page functions.
The **I2C_eeprom_cyclic_store** interface is documented [here](README_cyclic_store.md) The **I2C_eeprom_cyclic_store** interface is documented [here](README_cyclic_store.md)
#### RP2040 ### RP2040
There are at least two boards modules for the RP2040 that use a different Wire libraries. There are at least two boards modules for the RP2040 that use a different Wire libraries.
One from "Earle F. Philhower" and an "MBED" one. See issues #53 and #55 for details. One from "Earle F. Philhower" and an "MBED" one. See issues #53 and #55 for details.
@@ -36,7 +36,9 @@ to solve the issue #53 while being backwards compatible.
If a better solution is found, it will be implemented. If a better solution is found, it will be implemented.
#### Breaking change ### Breaking change
Version 1.9.0 fixed a memory leak in **verifyBlock()**.
Version 1.8.0 introduced a breaking change. Version 1.8.0 introduced a breaking change.
You cannot set the pins in **begin()** any more. You cannot set the pins in **begin()** any more.
@@ -45,7 +47,7 @@ The user has to call **Wire.begin()** and can optionally set the Wire pins
before calling **I2C_eeprom.begin()**. before calling **I2C_eeprom.begin()**.
#### Links ### Related
- https://github.com/RobTillaart/I2C_24LC1025 - https://github.com/RobTillaart/I2C_24LC1025
@@ -137,7 +139,6 @@ Same as write and update functions above. Returns true if successful, false indi
Returns true is buffer equals memoryAddres for length bytes. Returns true is buffer equals memoryAddres for length bytes.
### Other ### Other
- **uint32_t getDeviceSize()** idem - **uint32_t getDeviceSize()** idem
+1 -1
View File
@@ -15,7 +15,7 @@
"type": "git", "type": "git",
"url": "https://github.com/RobTillaart/I2C_EEPROM.git" "url": "https://github.com/RobTillaart/I2C_EEPROM.git"
}, },
"version": "1.8.5", "version": "1.9.0",
"license": "MIT", "license": "MIT",
"frameworks": "*", "frameworks": "*",
"platforms": "*", "platforms": "*",
+1 -1
View File
@@ -1,5 +1,5 @@
name=I2C_EEPROM name=I2C_EEPROM
version=1.8.5 version=1.9.0
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library for I2C EEPROMS sentence=Library for I2C EEPROMS