diff --git a/src/common.cc b/src/common.cc index c2ebd691..126f30a7 100644 --- a/src/common.cc +++ b/src/common.cc @@ -594,13 +594,13 @@ static int check_contains(char *f, char *s) int if_existing_iftest(struct text_object *obj) { char *spc; - int result; + int result = 0; spc = strchr(obj->data.s, ' '); if(spc != NULL) *spc = 0; if (access(obj->data.s, F_OK) == 0) { if(spc == NULL || check_contains(obj->data.s, spc + 1)) result = 1; - } else result = 0; + } if(spc != NULL) *spc = ' '; return result; } diff --git a/src/conky.cc b/src/conky.cc index a352690a..9c4b558b 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -1007,7 +1007,7 @@ static int get_string_width_special(char *s, int special_index) if(current_after_font->type == FONT) { influenced_by_font[i]=0; break; - } else strcpy(&influenced_by_font[i], &influenced_by_font[i+1]); + } else memmove(&influenced_by_font[i], &influenced_by_font[i+1], strlen(&influenced_by_font[i+1]) + 1); } } //add the length of influenced_by_font in the new font to width @@ -1019,7 +1019,8 @@ static int get_string_width_special(char *s, int special_index) //make sure there chars counted in the new font are not again counted in the old font int specials_skipped=0; while(i>0) { - if(p[specials_skipped]!=1) strcpy(&p[specials_skipped], &p[specials_skipped+1]); else specials_skipped++; + if(p[specials_skipped]!=1) memmove(&p[specials_skipped], &p[specials_skipped+1], strlen(&p[specials_skipped+1]) + 1); + else specials_skipped++; i--; } } diff --git a/src/eve.cc b/src/eve.cc index da4a1798..f4017642 100644 --- a/src/eve.cc +++ b/src/eve.cc @@ -291,13 +291,12 @@ static char *getSkillname(const char *file, int skillid) for (r = q->children; r; r = r->next) { xmlElementPtr ele = (xmlElementPtr) r; xmlAttrPtr attr = (xmlAttrPtr) ele->attributes; - char *mySkill; - int id, assigned = 0; + char *mySkill = NULL; + int id; while (attr != NULL) { if (!strcasecmp((const char *)attr->name, "typeName")) { mySkill = strdup((const char *)attr->children->content); - assigned = 1; } else if (!strcasecmp((const char *)attr->name, "typeID")) { id = atoi((const char *)attr->children->content); } @@ -305,12 +304,11 @@ static char *getSkillname(const char *file, int skillid) } if (id == skillid) { - skill = strdup(mySkill); - /* free(mySkill); */ + skill = mySkill; goto END; } - if (assigned) - free(mySkill); + + free(mySkill); } } } @@ -379,12 +377,10 @@ static char *eve(char *userid, char *apikey, char *charid) } if (parseTrainingXml(content, chr)) { - output = (char *)malloc(200 * sizeof(char)); - sprintf(output, "API error"); + output = strdup("API error"); return output; } - output = (char *)malloc(200 * sizeof(char)); timel = formatTime(&chr->ends); old_umask = umask(0066); tmp_fd = mkstemp(skillfile); @@ -398,6 +394,7 @@ static char *eve(char *userid, char *apikey, char *charid) chr->skillname = strdup(skill); + output = (char *)malloc(200 * sizeof(char)); sprintf(output, EVE_OUTPUT_FORMAT, chr->skillname, chr->level, timel); free(skill); return output; diff --git a/src/freebsd.cc b/src/freebsd.cc index 65be26ff..7fe2e36a 100644 --- a/src/freebsd.cc +++ b/src/freebsd.cc @@ -580,6 +580,11 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_fo int freq; char *freq_sysctl; + if (!p_client_buffer || client_buffer_size <= 0 || !p_format + || divisor <= 0) { + return 0; + } + freq_sysctl = (char *) calloc(16, sizeof(char)); if (freq_sysctl == NULL) { exit(-1); @@ -587,11 +592,6 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_fo snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1)); - if (!p_client_buffer || client_buffer_size <= 0 || !p_format - || divisor <= 0) { - return 0; - } - if (GETSYSCTL(freq_sysctl, freq) == 0) { snprintf(p_client_buffer, client_buffer_size, p_format, (float) freq / divisor); diff --git a/src/net_stat.cc b/src/net_stat.cc index 767a6391..85446ef9 100644 --- a/src/net_stat.cc +++ b/src/net_stat.cc @@ -507,8 +507,7 @@ void free_dns_data(struct text_object *obj) for (i = 0; i < dns_data.nscount; i++) free(dns_data.ns_list[i]); - if (dns_data.ns_list) - free(dns_data.ns_list); + free(dns_data.ns_list); memset(&dns_data, 0, sizeof(dns_data)); } diff --git a/src/proc.cc b/src/proc.cc index 85700026..037ed1e9 100644 --- a/src/proc.cc +++ b/src/proc.cc @@ -191,9 +191,9 @@ void print_pid_environ(struct text_object *obj, char *p, int p_max_size) } free(buf); } - free(var); *p = 0; } + free(var); } void print_pid_environ_list(struct text_object *obj, char *p, int p_max_size)