Skip to content

Commit 2bff509

Browse files
committed
fix GWG writing
1 parent 4740079 commit 2bff509

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/GWG/GWG.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,11 @@ bool GWG::write(const Datapoint& datapoint, const VariantValue& value) {
127127
return false;
128128
}
129129
uint8_t* payload = reinterpret_cast<uint8_t*>(malloc(datapoint.length()));
130-
if (!payload) {
131-
vw_log_i("writing not possible, packet creation error");
132-
return false;
133-
}
130+
if (!payload) return false;
134131
datapoint.encode(payload, datapoint.length(), value);
135-
return write(datapoint, payload, datapoint.length());
132+
bool result = write(datapoint, payload, datapoint.length());
133+
free(payload);
134+
return result;
136135
}
137136

138137
bool GWG::write(const Datapoint& datapoint, const uint8_t* data, uint8_t length) {

0 commit comments

Comments
 (0)