fix memory leak in SECoP protocol

This commit is contained in:
2024-11-14 09:10:10 +01:00
parent 4f6c943df5
commit 252fb370bd

View File

@ -113,7 +113,7 @@ int Secop3ProtHandler(Ascon *a) {
ret = Secop3ReadChars(a->fd, buffer, sizeof buffer - 1);
}
if (ret < 0) {
AsconError(a, "SECOP.1", errno);
AsconError(a, "SECoP.rd", errno);
}
switch (a->state) {
case AsconWriting:
@ -121,7 +121,7 @@ int Secop3ProtHandler(Ascon *a) {
l = GetDynStringLength(a->wrBuffer) - a->wrPos;
ret = AsconWriteChars(a->fd, GetCharArray(a->wrBuffer) + a->wrPos, l);
if (ret < 0) {
AsconError(a, "SECOP.2", errno); /* sets state to AsconFailed */
AsconError(a, "SECoP.wr", errno); /* sets state to AsconFailed */
} else {
a->wrPos += ret;
if (a->wrPos >= GetDynStringLength(a->wrBuffer)) {
@ -177,6 +177,7 @@ int Secop3ProtHandler(Ascon *a) {
tclobj = Tcl_NewListObj(2, tcllist);
}
DynStringCopy(a->rdBuffer, Tcl_GetString(tclobj));
Tcl_DecrRefCount(tclobj); /* this line avoids a big memory leak! */
a->responseValid = 1;
json_object_put(jobj); /* free jobj */
free(msg->message);