Skip to content

Commit

Permalink
Fix #74, memory leak in verifyBlock() (#75)
Browse files Browse the repository at this point in the history
- Fix #74, memory leak in setBlockVerify()
  • Loading branch information
RobTillaart authored Oct 9, 2024
1 parent 0de303f commit 8cb180d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).


## [1.9.0] - 2024-10-09
- Fix #74, memory leak in setBlockVerify() - kudos to cmichailidis

----

## [1.8.5] - 2024-04-22
- Fix #72, force requestFrom parameters to use int type


## [1.8.4] - 2024-04-20
- Fix #70, increase length internal buffer.
- add compile time flag **EN_AUTO_WRITE_PROTECT** (thanks to microfoundry)
Expand Down
8 changes: 6 additions & 2 deletions I2C_eeprom.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: I2C_eeprom.cpp
// AUTHOR: Rob Tillaart
// VERSION: 1.8.5
// VERSION: 1.9.0
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
// URL: https://github.com/RobTillaart/I2C_EEPROM

Expand Down Expand Up @@ -235,7 +235,11 @@ bool I2C_eeprom::setBlockVerify(const uint16_t memoryAddress, const uint8_t valu
if (setBlock(memoryAddress, value, length) != 0) return false;
uint8_t * data = (uint8_t *) malloc(length);
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++)
{
if (data[i] != value)
Expand Down
4 changes: 2 additions & 2 deletions I2C_eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: I2C_eeprom.h
// AUTHOR: Rob Tillaart
// VERSION: 1.8.5
// VERSION: 1.9.0
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
// URL: https://github.com/RobTillaart/I2C_EEPROM

Expand All @@ -11,7 +11,7 @@
#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_24LC256 32768
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Not supported is the identification page functions.
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.
One from "Earle F. Philhower" and an "MBED" one. See issues #53 and #55 for details.
Expand All @@ -36,7 +36,9 @@ to solve the issue #53 while being backwards compatible.
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.
You cannot set the pins in **begin()** any more.
Expand All @@ -45,7 +47,7 @@ The user has to call **Wire.begin()** and can optionally set the Wire pins
before calling **I2C_eeprom.begin()**.


#### Links
### Related

- https://github.com/RobTillaart/I2C_24LC1025

Expand Down Expand Up @@ -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.



### Other

- **uint32_t getDeviceSize()** idem
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/I2C_EEPROM.git"
},
"version": "1.8.5",
"version": "1.9.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=I2C_EEPROM
version=1.8.5
version=1.9.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library for I2C EEPROMS
Expand Down

0 comments on commit 8cb180d

Please sign in to comment.