Better error reporting through com_err
[mech_eap.orig] / display_status.c
index ebe66bd..44b5390 100644 (file)
@@ -62,30 +62,32 @@ createStatusInfoKey(void)
 static void
 saveStatusInfoNoCopy(OM_uint32 minor, char *message)
 {
-    struct gss_eap_status_info *info, *p;
+    struct gss_eap_status_info **next = NULL, *p;
 
     GSSEAP_ONCE(&gssEapStatusInfoKeyOnce, createStatusInfoKey);
 
-    info = GSSEAP_CALLOC(1, sizeof(*info));
-    if (info == NULL) {
-        GSSEAP_FREE(message);
-        return;
+    p = GSSEAP_GETSPECIFIC(gssEapStatusInfoKey);
+    for (; p != NULL; p = p->next) {
+        if (p->code == minor) {
+            p->message = message;
+            return;
+        }
+        next = &p->next;
     }
 
-    info->code = minor;
-    info->message = message;
-
-    p = GSSEAP_GETSPECIFIC(gssEapStatusInfoKey);
+    p = GSSEAP_CALLOC(1, sizeof(*p));
     if (p == NULL) {
-        GSSEAP_SETSPECIFIC(gssEapStatusInfoKey, info);
-    } else {
-        struct gss_eap_status_info **next = &p;
+        GSSEAP_FREE(message);
+        return;
+    }
 
-        for (; p != NULL; p = p->next)
-            next = &p->next;
+    p->code = minor;
+    p->message = message;
 
-        *next = info;
-    }
+    if (p != NULL)
+        *next = p;
+    else
+        GSSEAP_SETSPECIFIC(gssEapStatusInfoKey, p);
 }
 
 static const char *