mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Fix bad memory allocation
This commit is contained in:
parent
14b7acdab6
commit
d707d536bb
@ -749,17 +749,16 @@ static char *xoap_df = NULL;
|
|||||||
void load_xoap_keys(void)
|
void load_xoap_keys(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *par = (char *) malloc(11 * sizeof(char));
|
char *par = (char *) malloc(11 * sizeof(char));
|
||||||
char *key = (char *) malloc(17 * sizeof(char));
|
char *key = (char *) malloc(17 * sizeof(char));
|
||||||
char *xoap = NULL;
|
char *xoap = (char *) malloc(64 * sizeof(char));
|
||||||
|
|
||||||
xoap = (char *) malloc(64 * sizeof(char));
|
|
||||||
to_real_path(xoap, XOAP_FILE);
|
to_real_path(xoap, XOAP_FILE);
|
||||||
fp = fopen(xoap, "r");
|
fp = fopen(xoap, "r");
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
if (fscanf(fp, "%10s %16s", par, key) == 2) {
|
if (fscanf(fp, "%10s %16s", par, key) == 2) {
|
||||||
xoap_cc = (char *) malloc(64 * sizeof(char));
|
xoap_cc = (char *) malloc(128 * sizeof(char));
|
||||||
xoap_df = (char *) malloc(64 * sizeof(char));
|
xoap_df = (char *) malloc(128 * sizeof(char));
|
||||||
|
|
||||||
strcpy(xoap_cc, "?cc=*&link=xoap&prod=xoap&par=");
|
strcpy(xoap_cc, "?cc=*&link=xoap&prod=xoap&par=");
|
||||||
strcat(xoap_cc, par);
|
strcat(xoap_cc, par);
|
||||||
@ -772,17 +771,12 @@ void load_xoap_keys(void)
|
|||||||
strcat(xoap_df, "&key=");
|
strcat(xoap_df, "&key=");
|
||||||
strcat(xoap_df, key);
|
strcat(xoap_df, key);
|
||||||
strcat(xoap_df, "&unit=m");
|
strcat(xoap_df, "&unit=m");
|
||||||
} else {
|
|
||||||
free(xoap);
|
|
||||||
xoap = NULL;
|
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
|
||||||
free(xoap);
|
|
||||||
xoap = NULL;
|
|
||||||
}
|
}
|
||||||
free(par);
|
free(par);
|
||||||
free(key);
|
free(key);
|
||||||
|
free(xoap);
|
||||||
}
|
}
|
||||||
#endif /* XOAP */
|
#endif /* XOAP */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user