Fixes to coverity defects 87601 87557 87548 87547 87546 87545 87544 87536 87535 87529 87528

This commit is contained in:
Markus Makela
2015-02-22 22:29:30 +02:00
parent 22255a6045
commit 46c4fefb00
8 changed files with 16 additions and 10 deletions

View File

@ -1219,6 +1219,7 @@ inline void add_str(char** buf, int* buflen, int* bufsize, char* str)
if(*buf) if(*buf)
strcat(*buf," "); strcat(*buf," ");
} }
if(*buf)
strcat(*buf,str); strcat(*buf,str);
*buflen += isize; *buflen += isize;

View File

@ -632,7 +632,8 @@ static bool resolve_maxscale_homedir(
* 3. if /etc/MaxScale/MaxScale.cnf didn't exist or wasn't accessible, home * 3. if /etc/MaxScale/MaxScale.cnf didn't exist or wasn't accessible, home
* isn't specified. Thus, try to access $PWD/MaxScale.cnf . * isn't specified. Thus, try to access $PWD/MaxScale.cnf .
*/ */
tmp = strndup(getenv("PWD"), PATH_MAX); char *pwd = getenv("PWD");
tmp = strndup(pwd ? pwd : "PWD_NOT_SET", PATH_MAX);
tmp2 = get_expanded_pathname(p_home_dir, tmp, default_cnf_fname); tmp2 = get_expanded_pathname(p_home_dir, tmp, default_cnf_fname);
free(tmp2); /*< full path isn't needed so simply free it */ free(tmp2); /*< full path isn't needed so simply free it */

View File

@ -250,7 +250,7 @@ GWPROTOCOL *funcs;
else else
{ {
/* Save authentication data to file cache */ /* Save authentication data to file cache */
char *ptr, path[4096]; char *ptr, path[4097];
int mkdir_rval = 0; int mkdir_rval = 0;
strcpy(path, "/usr/local/skysql/MaxScale"); strcpy(path, "/usr/local/skysql/MaxScale");
if ((ptr = getenv("MAXSCALE_HOME")) != NULL) if ((ptr = getenv("MAXSCALE_HOME")) != NULL)

View File

@ -432,7 +432,7 @@ unsigned char *defuuid;
* Now start the replication from the master to MaxScale * Now start the replication from the master to MaxScale
*/ */
blr_start_master(inst); blr_start_master(inst);
free(name);
return (ROUTER *)inst; return (ROUTER *)inst;
} }

View File

@ -668,7 +668,7 @@ GWBUF *
blr_cache_read_response(ROUTER_INSTANCE *router, char *response) blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
{ {
struct stat statb; struct stat statb;
char path[4096], *ptr; char path[4097], *ptr;
int fd; int fd;
GWBUF *buf; GWBUF *buf;

View File

@ -142,6 +142,7 @@ GWBUF *buf;
sprintf(name, "%s Master", router->service->name); sprintf(name, "%s Master", router->service->name);
hktask_oneshot(name, blr_start_master, router, hktask_oneshot(name, blr_start_master, router,
BLR_MASTER_BACKOFF_TIME * router->retry_backoff++); BLR_MASTER_BACKOFF_TIME * router->retry_backoff++);
free(name);
} }
if (router->retry_backoff > BLR_MAX_BACKOFF) if (router->retry_backoff > BLR_MAX_BACKOFF)
router->retry_backoff = BLR_MAX_BACKOFF; router->retry_backoff = BLR_MAX_BACKOFF;
@ -203,11 +204,12 @@ GWBUF *ptr;
router->master_state = BLRM_UNCONNECTED; router->master_state = BLRM_UNCONNECTED;
if ((name = malloc(strlen(router->service->name) if ((name = malloc(strlen(router->service->name)
+ strlen(" Master")+1)) != NULL); + strlen(" Master")+1)) != NULL)
{ {
sprintf(name, "%s Master", router->service->name); sprintf(name, "%s Master", router->service->name);
hktask_oneshot(name, blr_start_master, router, hktask_oneshot(name, blr_start_master, router,
BLR_MASTER_BACKOFF_TIME * router->retry_backoff++); BLR_MASTER_BACKOFF_TIME * router->retry_backoff++);
free(name);
} }
if (router->retry_backoff > BLR_MAX_BACKOFF) if (router->retry_backoff > BLR_MAX_BACKOFF)
router->retry_backoff = BLR_MAX_BACKOFF; router->retry_backoff = BLR_MAX_BACKOFF;
@ -283,10 +285,11 @@ blr_master_delayed_connect(ROUTER_INSTANCE *router)
char *name; char *name;
if ((name = malloc(strlen(router->service->name) if ((name = malloc(strlen(router->service->name)
+ strlen(" Master Recovery")+1)) != NULL); + strlen(" Master Recovery")+1)) != NULL)
{ {
sprintf(name, "%s Master Recovery", router->service->name); sprintf(name, "%s Master Recovery", router->service->name);
hktask_oneshot(name, blr_start_master, router, 60); hktask_oneshot(name, blr_start_master, router, 60);
free(name);
} }
} }
@ -407,6 +410,7 @@ char query[128];
} }
router->master_state = BLRM_HBPERIOD; router->master_state = BLRM_HBPERIOD;
router->master->func.write(router->master, buf); router->master->func.write(router->master, buf);
free(val);
break; break;
} }
case BLRM_HBPERIOD: case BLRM_HBPERIOD:
@ -701,7 +705,7 @@ blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt)
{ {
uint8_t *msg = NULL, *ptr, *pdata; uint8_t *msg = NULL, *ptr, *pdata;
REP_HEADER hdr; REP_HEADER hdr;
unsigned int len, reslen; unsigned int len = 0, reslen;
unsigned int pkt_length; unsigned int pkt_length;
int no_residual = 1; int no_residual = 1;
int preslen = -1; int preslen = -1;

View File

@ -1371,7 +1371,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
GWBUF *head, *record; GWBUF *head, *record;
REP_HEADER hdr; REP_HEADER hdr;
int written, rval = 1, burst; int written, rval = 1, burst;
int rotating; int rotating = 0;
unsigned long burst_size; unsigned long burst_size;
uint8_t *ptr; uint8_t *ptr;

View File

@ -3758,7 +3758,7 @@ static GWBUF* sescmd_cursor_process_replies(
dcb_close(bref->bref_dcb); dcb_close(bref->bref_dcb);
*reconnect = true; *reconnect = true;
if(replybuf) if(replybuf)
gwbuf_free(replybuf); gwbuf_consume(replybuf,gwbuf_length(replybuf));
} }
} }
/** This is a response from the master and it is the "right" one. /** This is a response from the master and it is the "right" one.