crypto/x509/by_dir.c:193: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 191, column 24 is not reachable after line 193, column 17.
Showing all 78 steps of the trace


crypto/x509/by_dir.c:151:1: start of procedure add_cert_dir()
149.   }
150.   
151. > static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
152.   {
153.       int j, len;

crypto/x509/by_dir.c:156:9: Taking false branch
154.       const char *s, *ss, *p;
155.   
156.       if (dir == NULL || !*dir) {
               ^
157.           X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);
158.           return 0;

crypto/x509/by_dir.c:156:25: Taking false branch
154.       const char *s, *ss, *p;
155.   
156.       if (dir == NULL || !*dir) {
                               ^
157.           X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);
158.           return 0;

crypto/x509/by_dir.c:161:5: 
159.       }
160.   
161. >     s = dir;
162.       p = s;
163.       do {

crypto/x509/by_dir.c:162:5: 
160.   
161.       s = dir;
162. >     p = s;
163.       do {
164.           if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {

crypto/x509/by_dir.c:164:14: Taking true branch
162.       p = s;
163.       do {
164.           if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {
                    ^
165.               BY_DIR_ENTRY *ent;
166.               ss = s;

crypto/x509/by_dir.c:166:13: 
164.           if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {
165.               BY_DIR_ENTRY *ent;
166. >             ss = s;
167.               s = p + 1;
168.               len = (int)(p - ss);

crypto/x509/by_dir.c:167:13: 
165.               BY_DIR_ENTRY *ent;
166.               ss = s;
167. >             s = p + 1;
168.               len = (int)(p - ss);
169.               if (len == 0)

crypto/x509/by_dir.c:168:13: 
166.               ss = s;
167.               s = p + 1;
168. >             len = (int)(p - ss);
169.               if (len == 0)
170.                   continue;

crypto/x509/by_dir.c:169:17: Taking false branch
167.               s = p + 1;
168.               len = (int)(p - ss);
169.               if (len == 0)
                       ^
170.                   continue;
171.               for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {

crypto/x509/by_dir.c:171:18: 
169.               if (len == 0)
170.                   continue;
171. >             for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {
172.                   ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
173.                   if (strlen(ent->dir) == (size_t)len &&

crypto/x509/by_dir.c:171:25: 
169.               if (len == 0)
170.                   continue;
171. >             for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {
172.                   ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
173.                   if (strlen(ent->dir) == (size_t)len &&

crypto/x509/x509_lcl.h:142:1: start of procedure sk_BY_DIR_ENTRY_num()
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141.   DEFINE_STACK_OF(BY_DIR_HASH)
  142. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  144.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/stack/stack.c:277:1: start of procedure OPENSSL_sk_num()
    275.   }
    276.   
    277. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    278.   {
    279.       if (st == NULL)

crypto/stack/stack.c:279:9: Taking true branch
    277.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    278.   {
    279.       if (st == NULL)
                   ^
    280.           return -1;
    281.       return st->num;

crypto/stack/stack.c:280:9: 
    278.   {
    279.       if (st == NULL)
    280. >         return -1;
    281.       return st->num;
    282.   }

crypto/stack/stack.c:282:1: return from a call to OPENSSL_sk_num
    280.           return -1;
    281.       return st->num;
    282. > }
    283.   
    284.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

crypto/x509/x509_lcl.h:142:1: return from a call to sk_BY_DIR_ENTRY_num
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141.   DEFINE_STACK_OF(BY_DIR_HASH)
  142. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  144.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/x509/by_dir.c:171:25: Loop condition is false. Leaving loop
169.               if (len == 0)
170.                   continue;
171.               for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {
                               ^
172.                   ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
173.                   if (strlen(ent->dir) == (size_t)len &&

crypto/x509/by_dir.c:177:17: 
175.                       break;
176.               }
177. >             if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
178.                   continue;
179.               if (ctx->dirs == NULL) {

crypto/x509/x509_lcl.h:142:1: start of procedure sk_BY_DIR_ENTRY_num()
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141.   DEFINE_STACK_OF(BY_DIR_HASH)
  142. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  144.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/stack/stack.c:277:1: start of procedure OPENSSL_sk_num()
    275.   }
    276.   
    277. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    278.   {
    279.       if (st == NULL)

crypto/stack/stack.c:279:9: Taking true branch
    277.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    278.   {
    279.       if (st == NULL)
                   ^
    280.           return -1;
    281.       return st->num;

crypto/stack/stack.c:280:9: 
    278.   {
    279.       if (st == NULL)
    280. >         return -1;
    281.       return st->num;
    282.   }

crypto/stack/stack.c:282:1: return from a call to OPENSSL_sk_num
    280.           return -1;
    281.       return st->num;
    282. > }
    283.   
    284.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

crypto/x509/x509_lcl.h:142:1: return from a call to sk_BY_DIR_ENTRY_num
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141.   DEFINE_STACK_OF(BY_DIR_HASH)
  142. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  144.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/x509/by_dir.c:177:17: Taking false branch
175.                       break;
176.               }
177.               if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
                       ^
178.                   continue;
179.               if (ctx->dirs == NULL) {

crypto/x509/by_dir.c:179:17: Taking true branch
177.               if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
178.                   continue;
179.               if (ctx->dirs == NULL) {
                       ^
180.                   ctx->dirs = sk_BY_DIR_ENTRY_new_null();
181.                   if (!ctx->dirs) {

crypto/x509/by_dir.c:180:17: 
178.                   continue;
179.               if (ctx->dirs == NULL) {
180. >                 ctx->dirs = sk_BY_DIR_ENTRY_new_null();
181.                   if (!ctx->dirs) {
182.                       X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);

crypto/x509/x509_lcl.h:142:1: start of procedure sk_BY_DIR_ENTRY_new_null()
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141.   DEFINE_STACK_OF(BY_DIR_HASH)
  142. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  144.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/stack/stack.c:99:1: start of procedure OPENSSL_sk_new_null()
    97.   }
    98.   
    99. > OPENSSL_STACK *OPENSSL_sk_new_null(void)
    100.   {
    101.       return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);

crypto/stack/stack.c:101:5: Skipping OPENSSL_sk_new(): empty list of specs
    99.   OPENSSL_STACK *OPENSSL_sk_new_null(void)
    100.   {
    101.       return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);
               ^
    102.   }
    103.   

crypto/stack/stack.c:102:1: return from a call to OPENSSL_sk_new_null
    100.   {
    101.       return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);
    102. > }
    103.   
    104.   OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc c)

crypto/x509/x509_lcl.h:142:1: return from a call to sk_BY_DIR_ENTRY_new_null
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141.   DEFINE_STACK_OF(BY_DIR_HASH)
  142. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  144.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/x509/by_dir.c:181:22: Taking false branch
179.               if (ctx->dirs == NULL) {
180.                   ctx->dirs = sk_BY_DIR_ENTRY_new_null();
181.                   if (!ctx->dirs) {
                            ^
182.                       X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
183.                       return 0;

crypto/x509/by_dir.c:186:13: 
184.                   }
185.               }
186. >             ent = OPENSSL_malloc(sizeof(*ent));
187.               if (ent == NULL)
188.                   return 0;

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
  168.   #endif
  169.   
  170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  171.   {
  172.       void *ret = NULL;

crypto/mem.c:172:5: 
  170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  171.   {
  172. >     void *ret = NULL;
  173.   
  174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking true branch
  172.       void *ret = NULL;
  173.   
  174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  175.           return malloc_impl(num, file, line);
  176.   

crypto/mem.c:174:32: Taking true branch
  172.       void *ret = NULL;
  173.   
  174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                        ^
  175.           return malloc_impl(num, file, line);
  176.   

crypto/mem.c:175:9: Skipping __function_pointer__(): unresolved function pointer
  173.   
  174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  175.           return malloc_impl(num, file, line);
                 ^
  176.   
  177.       if (num == 0)

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
  194.   
  195.       return ret;
  196. > }
  197.   
  198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/x509/by_dir.c:187:17: Taking false branch
185.               }
186.               ent = OPENSSL_malloc(sizeof(*ent));
187.               if (ent == NULL)
                       ^
188.                   return 0;
189.               ent->dir_type = type;

crypto/x509/by_dir.c:189:13: 
187.               if (ent == NULL)
188.                   return 0;
189. >             ent->dir_type = type;
190.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
191.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);

crypto/x509/by_dir.c:190:13: 
188.                   return 0;
189.               ent->dir_type = type;
190. >             ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
191.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
192.               if (ent->dir == NULL || ent->hashes == NULL) {

crypto/x509/x509_lcl.h:141:1: start of procedure sk_BY_DIR_HASH_new()
  139.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141. > DEFINE_STACK_OF(BY_DIR_HASH)
  142.   DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/x509_lcl.h:141:1: return from a call to sk_BY_DIR_HASH_new
  139.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
  140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  141. > DEFINE_STACK_OF(BY_DIR_HASH)
  142.   DEFINE_STACK_OF(BY_DIR_ENTRY)
  143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/by_dir.c:191:13: 
189.               ent->dir_type = type;
190.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
191. >             ent->dir = OPENSSL_malloc((unsigned int)len + 1);
192.               if (ent->dir == NULL || ent->hashes == NULL) {
193.                   by_dir_entry_free(ent);

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
  168.   #endif
  169.   
  170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  171.   {
  172.       void *ret = NULL;

crypto/mem.c:172:5: 
  170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  171.   {
  172. >     void *ret = NULL;
  173.   
  174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking false branch
  172.       void *ret = NULL;
  173.   
  174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  175.           return malloc_impl(num, file, line);
  176.   

crypto/mem.c:177:9: Taking false branch
  175.           return malloc_impl(num, file, line);
  176.   
  177.       if (num == 0)
                 ^
  178.           return NULL;
  179.   

crypto/mem.c:181:5: 
  179.   
  180.       FAILTEST();
  181. >     allow_customize = 0;
  182.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  183.       if (call_malloc_debug) {

crypto/mem.c:191:5: 
  189.       }
  190.   #else
  191. >     (void)(file); (void)(line);
  192.       ret = malloc(num);
  193.   #endif

crypto/mem.c:191:19: 
  189.       }
  190.   #else
  191. >     (void)(file); (void)(line);
  192.       ret = malloc(num);
  193.   #endif

crypto/mem.c:192:5: 
  190.   #else
  191.       (void)(file); (void)(line);
  192. >     ret = malloc(num);
  193.   #endif
  194.   

crypto/mem.c:195:5: 
  193.   #endif
  194.   
  195. >     return ret;
  196.   }
  197.   

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
  194.   
  195.       return ret;
  196. > }
  197.   
  198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/x509/by_dir.c:192:17: Taking false branch
190.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
191.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
192.               if (ent->dir == NULL || ent->hashes == NULL) {
                       ^
193.                   by_dir_entry_free(ent);
194.                   return 0;

crypto/x509/by_dir.c:192:37: Taking true branch
190.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
191.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
192.               if (ent->dir == NULL || ent->hashes == NULL) {
                                           ^
193.                   by_dir_entry_free(ent);
194.                   return 0;

crypto/x509/by_dir.c:193:17: 
191.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
192.               if (ent->dir == NULL || ent->hashes == NULL) {
193. >                 by_dir_entry_free(ent);
194.                   return 0;
195.               }

crypto/x509/by_dir.c:133:1: start of procedure by_dir_entry_free()
  131.   }
  132.   
  133. > static void by_dir_entry_free(BY_DIR_ENTRY *ent)
  134.   {
  135.       OPENSSL_free(ent->dir);

crypto/x509/by_dir.c:135:5: 
  133.   static void by_dir_entry_free(BY_DIR_ENTRY *ent)
  134.   {
  135. >     OPENSSL_free(ent->dir);
  136.       sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  137.       OPENSSL_free(ent);

crypto/mem.c:265:1: start of procedure CRYPTO_free()
    263.   }
    264.   
    265. > void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:267:9: Taking true branch
    265.   void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    268.           free_impl(str, file, line);
    269.           return;

crypto/mem.c:267:30: Taking true branch
    265.   void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    268.           free_impl(str, file, line);
    269.           return;

crypto/mem.c:268:9: Skipping __function_pointer__(): unresolved function pointer
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    268.           free_impl(str, file, line);
                   ^
    269.           return;
    270.       }

crypto/mem.c:269:9: 
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    268.           free_impl(str, file, line);
    269. >         return;
    270.       }
    271.   

crypto/mem.c:283:1: return from a call to CRYPTO_free
    281.       free(str);
    282.   #endif
    283. > }
    284.   
    285.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/by_dir.c:136:5: 
  134.   {
  135.       OPENSSL_free(ent->dir);
  136. >     sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  137.       OPENSSL_free(ent);
  138.   }

crypto/x509/x509_lcl.h:141:1: start of procedure sk_BY_DIR_HASH_pop_free()
    139.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
    140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
    141. > DEFINE_STACK_OF(BY_DIR_HASH)
    142.   DEFINE_STACK_OF(BY_DIR_ENTRY)
    143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/x509_lcl.h:141:1: return from a call to sk_BY_DIR_HASH_pop_free
    139.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
    140.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
    141. > DEFINE_STACK_OF(BY_DIR_HASH)
    142.   DEFINE_STACK_OF(BY_DIR_ENTRY)
    143.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/by_dir.c:137:5: 
  135.       OPENSSL_free(ent->dir);
  136.       sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  137. >     OPENSSL_free(ent);
  138.   }
  139.   

crypto/mem.c:265:1: start of procedure CRYPTO_free()
    263.   }
    264.   
    265. > void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:267:9: Taking false branch
    265.   void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    268.           free_impl(str, file, line);
    269.           return;

crypto/mem.c:281:5: 
    279.       }
    280.   #else
    281. >     free(str);
    282.   #endif
    283.   }

crypto/mem.c:283:1: return from a call to CRYPTO_free
    281.       free(str);
    282.   #endif
    283. > }
    284.   
    285.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/by_dir.c:138:1: return from a call to by_dir_entry_free
  136.       sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  137.       OPENSSL_free(ent);
  138. > }
  139.   
  140.   static void free_dir(X509_LOOKUP *lu)

static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
{
    int j, len;
    const char *s, *ss, *p;
    if (dir == NULL || !*dir) {
        X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);
        return 0;
    }
    s = dir;
    p = s;
    do {
        if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {
            BY_DIR_ENTRY *ent;
            ss = s;
            s = p + 1;
            len = (int)(p - ss);
            if (len == 0)
                continue;
            for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {
                ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
                if (strlen(ent->dir) == (size_t)len &&
                    strncmp(ent->dir, ss, (unsigned int)len) == 0)
                    break;
            }
            if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
                continue;
            if (ctx->dirs == NULL) {
                ctx->dirs = sk_BY_DIR_ENTRY_new_null();
                if (!ctx->dirs) {
                    X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
                    return 0;
                }
            }
            ent = OPENSSL_malloc(sizeof(*ent));
            if (ent == NULL)
                return 0;
            ent->dir_type = type;
            ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
            ent->dir = OPENSSL_malloc((unsigned int)len + 1);
            if (ent->dir == NULL || ent->hashes == NULL) {
                by_dir_entry_free(ent);
                return 0;
            }
            strncpy(ent->dir, ss, (unsigned int)len);
            ent->dir[len] = '\0';
            if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) {
                by_dir_entry_free(ent);
                return 0;
            }
        }
    } while (*p++ != '\0');
    return 1;
}
["static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)\n{\n    int j, len;\n    const char *s, *ss, *p;\n    if (dir == NULL || !*dir) {\n        X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);\n        return 0;\n    }\n    s = dir;\n    p = s;\n    do {\n        if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\\0')) {\n            BY_DIR_ENTRY *ent;\n            ss = s;\n            s = p + 1;\n            len = (int)(p - ss);\n            if (len == 0)\n                continue;\n            for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {\n                ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);\n                if (strlen(ent->dir) == (size_t)len &&\n                    strncmp(ent->dir, ss, (unsigned int)len) == 0)\n                    break;\n            }\n            if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))\n                continue;\n            if (ctx->dirs == NULL) {\n                ctx->dirs = sk_BY_DIR_ENTRY_new_null();\n                if (!ctx->dirs) {\n                    X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);\n                    return 0;\n                }\n            }\n            ent = OPENSSL_malloc(sizeof(*ent));\n            if (ent == NULL)\n                return 0;\n            ent->dir_type = type;\n            ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);\n            ent->dir = OPENSSL_malloc((unsigned int)len + 1);\n            if (ent->dir == NULL || ent->hashes == NULL) {\n                by_dir_entry_free(ent);\n                return 0;\n            }\n            strncpy(ent->dir, ss, (unsigned int)len);\n            ent->dir[len] = '\\0';\n            if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) {\n                by_dir_entry_free(ent);\n                return 0;\n            }\n        }\n    } while (*p++ != '\\0');\n    return 1;\n}", 'int OPENSSL_sk_num(const OPENSSL_STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', 'OPENSSL_STACK *OPENSSL_sk_new_null(void)\n{\n    return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'static void by_dir_entry_free(BY_DIR_ENTRY *ent)\n{\n    OPENSSL_free(ent->dir);\n    sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);\n    OPENSSL_free(ent);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']