Fixes to Coverity defects 84879 84878 72752 72742

This commit is contained in:
Markus Makela
2014-12-15 06:12:40 +02:00
parent a4968f2521
commit 04a92e40df
4 changed files with 10 additions and 8 deletions

View File

@ -234,7 +234,7 @@ modutil_get_query(GWBUF *buf)
uint8_t* packet;
mysql_server_cmd_t packet_type;
size_t len;
char* query_str;
char* query_str = NULL;
packet = GWBUF_DATA(buf);
packet_type = packet[4];
@ -252,7 +252,7 @@ modutil_get_query(GWBUF *buf)
case MYSQL_COM_QUERY:
len = MYSQL_GET_PACKET_LEN(packet)-1; /*< distract 1 for packet type byte */
if ((query_str = (char *)malloc(len+1)) == NULL)
if (len < 1 || (query_str = (char *)malloc(len+1)) == NULL)
{
goto retblock;
}
@ -262,7 +262,7 @@ modutil_get_query(GWBUF *buf)
default:
len = strlen(STRPACKETTYPE(packet_type))+1;
if ((query_str = (char *)malloc(len+1)) == NULL)
if (len < 1 || (query_str = (char *)malloc(len+1)) == NULL)
{
goto retblock;
}