s3:idmap_cache: add common exit point to idmap_cache_find_sid2unixid()
authorMichael Adam <obnox@samba.org>
Wed, 16 May 2012 21:10:04 +0000 (23:10 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 18 May 2012 12:44:15 +0000 (14:44 +0200)
source3/lib/idmap_cache.c

index 8bad6e4eab630e4d748273f1498ab7c7e4688ead..0d792d456cabec39000aafd13603ee4ce12ee935 100644 (file)
@@ -37,7 +37,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
 {
        fstring sidstr;
        char *key;
-       char *value;
+       char *value = NULL;
        char *endptr;
        time_t timeout;
        bool ret;
@@ -50,8 +50,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
        }
        ret = gencache_get(key, &value, &timeout);
        if (!ret) {
-               TALLOC_FREE(key);
-               return false;
+               goto done;
        }
 
        DEBUG(10, ("Parsing value for key [%s]: value=[%s]\n", key, value));
@@ -76,31 +75,28 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
                        break;
 
                case '\0':
-                       TALLOC_FREE(key);
-                       SAFE_FREE(value);
                        DEBUG(0, ("FAILED to parse value for key [%s] "
                                  "(id=[%llu], endptr=[%s]): "
                                  "no type character after colon\n",
                                  key, (unsigned long long)tmp_id.id, endptr));
-                       return false;
+                       ret = false;
+                       goto done;
                default:
-                       TALLOC_FREE(key);
-                       SAFE_FREE(value);
                        DEBUG(0, ("FAILED to parse value for key [%s] "
                                  "(id=[%llu], endptr=[%s]): "
                                  "illegal type character '%c'\n",
                                  key, (unsigned long long)tmp_id.id, endptr,
                                  endptr[1]));
-                       return false;
+                       ret = false;
+                       goto done;
                }
                if (endptr[2] != '\0') {
-                       TALLOC_FREE(key);
-                       SAFE_FREE(value);
                        DEBUG(0, ("FAILED to parse value for key [%s] "
                                  "(id=[%llu], endptr=[%s]): "
                                  "more than 1 type character after colon\n",
                                  key, (unsigned long long)tmp_id.id, endptr));
-                       return false;
+                       ret = false;
+                       goto done;
                }
 
                *id = tmp_id;
@@ -110,6 +106,8 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
                          "colon missing after id=[%llu]\n",
                          key, value, (unsigned long long)tmp_id.id));
        }
+
+done:
        TALLOC_FREE(key);
        SAFE_FREE(value);
        return ret;