S
sangeetha_b
Hello,
I've writen one simple program to automate some manual process. I've
written that in c program. It works fine so far no problem reported on
this. Last week, i get chance to run my program on purify tool. I'm
very new to purify tool use.
Q1. Purify reports Uninitialized memory read in the following line A
and Line B
<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>
int parameter_parse(char *ptr)
{
char *tmp;
PARAM *p_tmp;
p_tmp = (struct PARAM *)malloc(sizeof(struct PARAM));
if (!( tmp = strchr(ptr, '=') ))
printf("\nBailing out..");
exit (1);
}
tmp++; // since ptr includes delimiters too ("=")
p_tmp->value = strdup(tmp);
p_tmp->field =
(char *)malloc(strlen(ptr)-strlen(p_tmp->value)); // Line A
strncat(p_tmp->field, ptr,
(strlen(ptr)-strlen(p_tmp->value)-1)); // Line B
p_tmp->next = NULL;
if ( p_start == NULL)
{
p_start = p_tmp;
p_last = p_tmp;
} else {
p_last->next = p_tmp;
p_last = p_tmp;
}
return 0;
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>
This "parameter_parse" funciton receives input in this form
"key=value". I dont know wht is the "Uninitialized memory read" memory
read at these two lines.
Q2. Similarly, it shows UMR in the following two lines
if ( t == NUMERIC )
strcat(res, NUMBER[9]); // Line C
else
strcat(res, ALPHABETS[9]); // Line D
Here, NUMBER and ALPHABETS are an array of 10 pointers-to-int.
Please help me to resolve this problem.
Thanks in advance.
Wluve,
Sangeetha.
I've writen one simple program to automate some manual process. I've
written that in c program. It works fine so far no problem reported on
this. Last week, i get chance to run my program on purify tool. I'm
very new to purify tool use.
Q1. Purify reports Uninitialized memory read in the following line A
and Line B
<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>
int parameter_parse(char *ptr)
{
char *tmp;
PARAM *p_tmp;
p_tmp = (struct PARAM *)malloc(sizeof(struct PARAM));
if (!( tmp = strchr(ptr, '=') ))
printf("\nBailing out..");
exit (1);
}
tmp++; // since ptr includes delimiters too ("=")
p_tmp->value = strdup(tmp);
p_tmp->field =
(char *)malloc(strlen(ptr)-strlen(p_tmp->value)); // Line A
strncat(p_tmp->field, ptr,
(strlen(ptr)-strlen(p_tmp->value)-1)); // Line B
p_tmp->next = NULL;
if ( p_start == NULL)
{
p_start = p_tmp;
p_last = p_tmp;
} else {
p_last->next = p_tmp;
p_last = p_tmp;
}
return 0;
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>
This "parameter_parse" funciton receives input in this form
"key=value". I dont know wht is the "Uninitialized memory read" memory
read at these two lines.
Q2. Similarly, it shows UMR in the following two lines
if ( t == NUMERIC )
strcat(res, NUMBER[9]); // Line C
else
strcat(res, ALPHABETS[9]); // Line D
Here, NUMBER and ALPHABETS are an array of 10 pointers-to-int.
Please help me to resolve this problem.
Thanks in advance.
Wluve,
Sangeetha.