svn rev #25045: trunk/src/util/profile/
ghudson@MIT.EDU
ghudson at MIT.EDU
Mon Jul 25 11:54:33 EDT 2011
http://src.mit.edu/fisheye/changelog/krb5/?cs=25045
Commit By: ghudson
Log Message:
Rewrite set_results() in prof_get.c.
The new implementation should be more friendly to static analyzers.
Coverity was getting confused into thinking that profile_iterator()
had the effect of returning a freed name pointer.
Changed Files:
U trunk/src/util/profile/prof_get.c
Modified: trunk/src/util/profile/prof_get.c
===================================================================
--- trunk/src/util/profile/prof_get.c 2011-07-25 15:54:30 UTC (rev 25044)
+++ trunk/src/util/profile/prof_get.c 2011-07-25 15:54:33 UTC (rev 25045)
@@ -544,28 +544,31 @@
set_results(const char *name, const char *value, char **ret_name,
char **ret_value)
{
- if (ret_name) {
- if (name) {
- *ret_name = strdup(name);
- if (!*ret_name)
- return ENOMEM;
- } else
- *ret_name = NULL;
+ char *name_copy = NULL, *value_copy = NULL;
+
+ if (ret_name && name) {
+ name_copy = strdup(name);
+ if (name_copy == NULL)
+ goto oom;
}
- if (ret_value) {
- if (value) {
- *ret_value = strdup(value);
- if (!*ret_value) {
- if (ret_name) {
- free(*ret_name);
- *ret_name = NULL;
- }
- return ENOMEM;
- }
- } else
- *ret_value = NULL;
+ if (ret_value && value) {
+ value_copy = strdup(value);
+ if (value_copy == NULL)
+ goto oom;
}
+ if (ret_name)
+ *ret_name = name_copy;
+ if (ret_value)
+ *ret_value = value_copy;
return 0;
+oom:
+ free(name_copy);
+ free(value_copy);
+ if (ret_name)
+ *ret_name = NULL;
+ if (ret_value)
+ *ret_value = NULL;
+ return ENOMEM;
}
errcode_t KRB5_CALLCONV
More information about the cvs-krb5
mailing list