Fix Coverity Scan CID 342010

Fix a few cppcheck errors/warnings

Signed-off-by: Raphael Defosseux <raphael.defosseux@eurecom.fr>
This commit is contained in:
Raphael Defosseux
2019-07-05 11:03:30 +02:00
parent d2a6cca8f9
commit 3f2acf9485
5 changed files with 20 additions and 10 deletions
+9 -2
View File
@@ -125,8 +125,15 @@ int main(int argc, char *argv[]) {
fullwrite(serviceSock, &header, sizeof(header));
int dataSize=sizeof(sample_t)*header.size*header.nbAnt;
if (dataSize>bufSize)
buff=realloc(buff,dataSize);
if (dataSize>bufSize) {
void * new_buff = realloc(buff, dataSize);
if (new_buff == NULL) {
free(buff);
AssertFatal(1, "Could not reallocate");
} else {
buff = new_buff;
}
}
AssertFatal(read(fd,buff,dataSize) == dataSize, "");
fullwrite(serviceSock, buff, dataSize);