Fixes to Coverity tasks : 73267, 72686, 72672

Cleaned up warnings, and added checks to malloc return values and error log writes in case of failures.
This commit is contained in:
VilhoRaatikka
2014-10-31 15:25:59 +02:00
parent 848c7aa0b8
commit 00fded016b
9 changed files with 123 additions and 32 deletions

View File

@ -245,7 +245,7 @@ GWBUF *modutil_create_mysql_err_msg(
int affected_rows,
int merrno,
const char *statemsg,
const char * msg)
const char *msg)
{
uint8_t *outbuf = NULL;
uint8_t mysql_payload_size = 0;
@ -259,6 +259,10 @@ GWBUF *modutil_create_mysql_err_msg(
const char *mysql_state = NULL;
GWBUF *errbuf = NULL;
if (statemsg == NULL || msg == NULL)
{
return NULL;
}
mysql_errno = (unsigned int)merrno;
mysql_error_msg = msg;
mysql_state = statemsg;
@ -270,9 +274,6 @@ GWBUF *modutil_create_mysql_err_msg(
mysql_statemsg[0]='#';
memcpy(mysql_statemsg+1, mysql_state, 5);
if (msg != NULL) {
mysql_error_msg = msg;
}
mysql_payload_size = sizeof(field_count) +
sizeof(mysql_err) +
sizeof(mysql_statemsg) +
@ -283,8 +284,9 @@ GWBUF *modutil_create_mysql_err_msg(
ss_dassert(errbuf != NULL);
if (errbuf == NULL)
{
return NULL;
}
outbuf = GWBUF_DATA(errbuf);
/** write packet header and packet number */