svn rev #23117: trunk/src/util/support/

ghudson@MIT.EDU ghudson at MIT.EDU
Sun Nov 1 17:14:26 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=23117
Commit By: ghudson
Log Message:
Be a little more const-correct in krb5int_vset_error_fl.



Changed Files:
U   trunk/src/util/support/errors.c
Modified: trunk/src/util/support/errors.c
===================================================================
--- trunk/src/util/support/errors.c	2009-11-01 21:51:26 UTC (rev 23116)
+++ trunk/src/util/support/errors.c	2009-11-01 22:14:25 UTC (rev 23117)
@@ -68,20 +68,17 @@
 {
     va_list args2;
     char *str = NULL, *str2, *slash;
-    const char *loc_fmt = NULL;
-
 #ifdef USE_KIM
+    kim_string loc_fmt = NULL;
+
     /* Try to localize the format string */
-    if (kim_os_string_create_localized(&loc_fmt, fmt) != KIM_NO_ERROR) {
-        loc_fmt = fmt;
-    }
-#else
-    loc_fmt = fmt;
+    if (kim_os_string_create_localized(&loc_fmt, fmt) == KIM_NO_ERROR)
+        fmt = loc_fmt;
 #endif
 
     /* try vasprintf first */
     va_copy(args2, args);
-    if (vasprintf(&str, loc_fmt, args2) < 0) {
+    if (vasprintf(&str, fmt, args2) < 0) {
 	str = NULL;
     }
     va_end(args2);
@@ -99,22 +96,20 @@
 
     /* If that failed, try using scratch_buf */
     if (str == NULL) {
-        vsnprintf(ep->scratch_buf, sizeof(ep->scratch_buf), loc_fmt, args);
+        vsnprintf(ep->scratch_buf, sizeof(ep->scratch_buf), fmt, args);
         str = strdup(ep->scratch_buf); /* try allocating again */
     }
 
     /* free old string before setting new one */
     if (ep->msg && ep->msg != ep->scratch_buf) {
-	free ((char *) ep->msg);
+	krb5int_free_error (ep, ep->msg);
 	ep->msg = NULL;
     }
     ep->code = code;
     ep->msg = str ? str : ep->scratch_buf;
 
 #ifdef USE_KIM
-    if (loc_fmt != fmt) { kim_string_free(&loc_fmt); }
-#else
-    if (loc_fmt != fmt) { free((char *) loc_fmt); }
+    kim_string_free(&loc_fmt);
 #endif
 }
 




More information about the cvs-krb5 mailing list