Skip to content
Snippets Groups Projects
Commit a8b6e759 authored by clohr's avatar clohr
Browse files

valgrind

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/C/branches/version-0.7@2289 b32b6428-25c9-4566-ad07-03861ab6144f
parent 5d6bb1b7
Branches
No related tags found
No related merge requests found
......@@ -422,6 +422,7 @@ bool xAAL_read_bus(const xAAL_businfo_t *bus,
return false;
} else if (!cbor_isa_array(cpayload) || cbor_array_is_indefinite(cpayload) || (cbor_array_size(cpayload)<4) || (cbor_array_size(cpayload)>5) ) {
if (xAAL_error_log) fprintf(xAAL_error_log, "Decoded 'payload' field is not a cbor defined array[4|5]\n");
cbor_decref(&cpayload);
cbor_decref(ctargets);
cbor_decref(&cmsg);
return false;
......@@ -440,8 +441,8 @@ bool xAAL_read_bus(const xAAL_businfo_t *bus,
*source = (uuid_t *)malloc(sizeof(uuid_t));
if ( !xAAL_cbor_is_uuid(csource, *source) ) {
if (xAAL_error_log) fprintf(xAAL_error_log, "Invalid 'source' field in xAAL header\n");
cbor_decref(ctargets);
cbor_decref(&cmsg);
cbor_decref(ctargets);
cbor_decref(&cpayload);
return false;
}
......@@ -476,6 +477,7 @@ bool xAAL_read_bus(const xAAL_businfo_t *bus,
if (xAAL_error_log) fprintf(xAAL_error_log, "Invalid 'action' field in xAAL header\n");
cbor_decref(&cmsg);
cbor_decref(ctargets);
cbor_decref(&cpayload);
free(*source);
free(*devType);
return false;
......@@ -492,6 +494,7 @@ bool xAAL_read_bus(const xAAL_businfo_t *bus,
cbor_decref(&cmsg);
cbor_decref(ctargets);
cbor_decref(cbody);
cbor_decref(&cpayload);
free(*source);
free(*devType);
free(*action);
......@@ -499,6 +502,7 @@ bool xAAL_read_bus(const xAAL_businfo_t *bus,
}
cbor_decref(&cmsg);
cbor_decref(&cpayload);
return true;
}
......@@ -550,11 +554,12 @@ bool xAAL_write_bus(const xAAL_businfo_t *bus,
r = r && (msgType <= xAAL_MSGTYPE_LAST);
r = r && cbor_array_set(cpayload, 2, cbor_move(cbor_build_uint8(msgType)) ); /* msgType */
r = r && cbor_array_set(cpayload, 3, cbor_move(cbor_build_string(action)) ); /* action */
if ( cbody )
r = r && cbor_array_set(cpayload, 4, cbor_move(cbody) ); /* body if any */
if ( cbody ) {
r = r && cbor_array_set(cpayload, 4, cbody); /* body if any */
cbor_decref(&cbody);
}
if ( !r ) {
cbor_decref(&cpayload);
if (cbody) cbor_decref(&cbody);
if (ctargets) cbor_decref(&ctargets);
return false;
}
......@@ -579,7 +584,6 @@ bool xAAL_write_bus(const xAAL_businfo_t *bus,
if ( !r ) {
cbor_decref(&cpayload);
free(c);
if (cbody) cbor_decref(&cbody);
if (ctargets) cbor_decref(&ctargets);
return false;
}
......@@ -600,13 +604,12 @@ bool xAAL_write_bus(const xAAL_businfo_t *bus,
if ( !r ) {
cbor_decref(&cpayload);
cbor_decref(&cmsg); /* note: buffer c is included and should be deallocated automaticaly */
if (cbody) cbor_decref(&cbody);
if (ctargets) cbor_decref(&ctargets);
return false;
}
/* Send message */
cbor_serialize_alloc(cmsg, &msg, &msglen);
msglen = cbor_serialize_alloc(cmsg, &msg, &sz);
if ( sendto(bus->sfd, msg, msglen, 0, (struct sockaddr *)&(bus->addr), bus->addrlen) == -1) {
if (xAAL_error_log) fprintf(xAAL_error_log, "Error while sending message: %s\n", strerror(errno));
......@@ -615,7 +618,6 @@ bool xAAL_write_bus(const xAAL_businfo_t *bus,
cbor_decref(&cpayload);
cbor_decref(&cmsg);
if (cbody) cbor_decref(&cbody);
if (ctargets) cbor_decref(&ctargets);
free(msg);
return r;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment