Skip to content

Commit

Permalink
Fix #74, memory leak in verifyBlock()
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Oct 9, 2024
1 parent 0de303f commit f556308
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ If a better solution is found, it will be implemented.

#### 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.
This reduces the dependency of processor dependent Wire implementations.
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 <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Library for I2C EEPROMS
Expand Down

0 comments on commit f556308

Please sign in to comment.