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


crypto/x509/by_dir.c:193:1: start of procedure add_cert_dir()
191.   }
192.   
193. > static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
194.   {
195.       int j, len;

crypto/x509/by_dir.c:198:9: Taking false branch
196.       const char *s, *ss, *p;
197.   
198.       if (dir == NULL || !*dir) {
               ^
199.           X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);
200.           return 0;

crypto/x509/by_dir.c:198:25: Taking false branch
196.       const char *s, *ss, *p;
197.   
198.       if (dir == NULL || !*dir) {
                               ^
199.           X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);
200.           return 0;

crypto/x509/by_dir.c:203:5: 
201.       }
202.   
203. >     s = dir;
204.       p = s;
205.       do {

crypto/x509/by_dir.c:204:5: 
202.   
203.       s = dir;
204. >     p = s;
205.       do {
206.           if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {

crypto/x509/by_dir.c:206:14: Taking true branch
204.       p = s;
205.       do {
206.           if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {
                    ^
207.               BY_DIR_ENTRY *ent;
208.               ss = s;

crypto/x509/by_dir.c:208:13: 
206.           if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {
207.               BY_DIR_ENTRY *ent;
208. >             ss = s;
209.               s = p + 1;
210.               len = (int)(p - ss);

crypto/x509/by_dir.c:209:13: 
207.               BY_DIR_ENTRY *ent;
208.               ss = s;
209. >             s = p + 1;
210.               len = (int)(p - ss);
211.               if (len == 0)

crypto/x509/by_dir.c:210:13: 
208.               ss = s;
209.               s = p + 1;
210. >             len = (int)(p - ss);
211.               if (len == 0)
212.                   continue;

crypto/x509/by_dir.c:211:17: Taking false branch
209.               s = p + 1;
210.               len = (int)(p - ss);
211.               if (len == 0)
                       ^
212.                   continue;
213.               for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {

crypto/x509/by_dir.c:213:18: 
211.               if (len == 0)
212.                   continue;
213. >             for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {
214.                   ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
215.                   if (strlen(ent->dir) == (size_t)len &&

crypto/x509/by_dir.c:213:25: 
211.               if (len == 0)
212.                   continue;
213. >             for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {
214.                   ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
215.                   if (strlen(ent->dir) == (size_t)len &&

crypto/x509/x509_lcl.h:119:1: start of procedure sk_BY_DIR_ENTRY_num()
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118.   DEFINE_STACK_OF(BY_DIR_HASH)
  119. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  121.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/stack/stack.c:316:1: start of procedure sk_num()
    314.   }
    315.   
    316. > int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)

crypto/stack/stack.c:318:9: Taking true branch
    316.   int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)
                   ^
    319.           return -1;
    320.       return st->num;

crypto/stack/stack.c:319:9: 
    317.   {
    318.       if (st == NULL)
    319. >         return -1;
    320.       return st->num;
    321.   }

crypto/stack/stack.c:321:1: return from a call to sk_num
    319.           return -1;
    320.       return st->num;
    321. > }
    322.   
    323.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_lcl.h:119:1: return from a call to sk_BY_DIR_ENTRY_num
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118.   DEFINE_STACK_OF(BY_DIR_HASH)
  119. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  121.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

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

crypto/x509/by_dir.c:219:17: 
217.                       break;
218.               }
219. >             if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
220.                   continue;
221.               if (ctx->dirs == NULL) {

crypto/x509/x509_lcl.h:119:1: start of procedure sk_BY_DIR_ENTRY_num()
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118.   DEFINE_STACK_OF(BY_DIR_HASH)
  119. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  121.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/stack/stack.c:316:1: start of procedure sk_num()
    314.   }
    315.   
    316. > int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)

crypto/stack/stack.c:318:9: Taking true branch
    316.   int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)
                   ^
    319.           return -1;
    320.       return st->num;

crypto/stack/stack.c:319:9: 
    317.   {
    318.       if (st == NULL)
    319. >         return -1;
    320.       return st->num;
    321.   }

crypto/stack/stack.c:321:1: return from a call to sk_num
    319.           return -1;
    320.       return st->num;
    321. > }
    322.   
    323.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_lcl.h:119:1: return from a call to sk_BY_DIR_ENTRY_num
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118.   DEFINE_STACK_OF(BY_DIR_HASH)
  119. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  121.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/x509/by_dir.c:219:17: Taking false branch
217.                       break;
218.               }
219.               if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
                       ^
220.                   continue;
221.               if (ctx->dirs == NULL) {

crypto/x509/by_dir.c:221:17: Taking true branch
219.               if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
220.                   continue;
221.               if (ctx->dirs == NULL) {
                       ^
222.                   ctx->dirs = sk_BY_DIR_ENTRY_new_null();
223.                   if (!ctx->dirs) {

crypto/x509/by_dir.c:222:17: 
220.                   continue;
221.               if (ctx->dirs == NULL) {
222. >                 ctx->dirs = sk_BY_DIR_ENTRY_new_null();
223.                   if (!ctx->dirs) {
224.                       X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);

crypto/x509/x509_lcl.h:119:1: start of procedure sk_BY_DIR_ENTRY_new_null()
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118.   DEFINE_STACK_OF(BY_DIR_HASH)
  119. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  121.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/stack/stack.c:144:1: start of procedure sk_new_null()
    142.   }
    143.   
    144. > _STACK *sk_new_null(void)
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);

crypto/stack/stack.c:146:5: Skipping sk_new(): empty list of specs
    144.   _STACK *sk_new_null(void)
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);
               ^
    147.   }
    148.   

crypto/stack/stack.c:147:1: return from a call to sk_new_null
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);
    147. > }
    148.   
    149.   _STACK *sk_new(int (*c) (const void *, const void *))

crypto/x509/x509_lcl.h:119:1: return from a call to sk_BY_DIR_ENTRY_new_null
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118.   DEFINE_STACK_OF(BY_DIR_HASH)
  119. > DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
  121.   DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

crypto/x509/by_dir.c:223:22: Taking false branch
221.               if (ctx->dirs == NULL) {
222.                   ctx->dirs = sk_BY_DIR_ENTRY_new_null();
223.                   if (!ctx->dirs) {
                            ^
224.                       X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
225.                       return 0;

crypto/x509/by_dir.c:228:13: 
226.                   }
227.               }
228. >             ent = OPENSSL_malloc(sizeof(*ent));
229.               if (ent == NULL)
230.                   return 0;

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
  117.   }
  118.   
  119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121.       void *ret = NULL;

crypto/mem.c:121:5: 
  119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121. >     void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking true branch
  121.       void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  124.           return malloc_impl(num, file, line);
  125.   

crypto/mem.c:123:32: Taking true branch
  121.       void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                        ^
  124.           return malloc_impl(num, file, line);
  125.   

crypto/mem.c:124:9: Skipping __function_pointer__(): unresolved function pointer
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  124.           return malloc_impl(num, file, line);
                 ^
  125.   
  126.       if (num <= 0)

crypto/mem.c:157:1: return from a call to CRYPTO_malloc
  155.   
  156.       return ret;
  157. > }
  158.   
  159.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/x509/by_dir.c:229:17: Taking false branch
227.               }
228.               ent = OPENSSL_malloc(sizeof(*ent));
229.               if (ent == NULL)
                       ^
230.                   return 0;
231.               ent->dir_type = type;

crypto/x509/by_dir.c:231:13: 
229.               if (ent == NULL)
230.                   return 0;
231. >             ent->dir_type = type;
232.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
233.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);

crypto/x509/by_dir.c:232:13: 
230.                   return 0;
231.               ent->dir_type = type;
232. >             ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
233.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
234.               if (ent->dir == NULL || ent->hashes == NULL) {

crypto/x509/x509_lcl.h:118:1: start of procedure sk_BY_DIR_HASH_new()
  116.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118. > DEFINE_STACK_OF(BY_DIR_HASH)
  119.   DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/x509_lcl.h:118:1: return from a call to sk_BY_DIR_HASH_new
  116.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
  117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
  118. > DEFINE_STACK_OF(BY_DIR_HASH)
  119.   DEFINE_STACK_OF(BY_DIR_ENTRY)
  120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/by_dir.c:233:13: 
231.               ent->dir_type = type;
232.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
233. >             ent->dir = OPENSSL_malloc((unsigned int)len + 1);
234.               if (ent->dir == NULL || ent->hashes == NULL) {
235.                   by_dir_entry_free(ent);

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
  117.   }
  118.   
  119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121.       void *ret = NULL;

crypto/mem.c:121:5: 
  119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121. >     void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
  121.       void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  124.           return malloc_impl(num, file, line);
  125.   

crypto/mem.c:126:9: Taking false branch
  124.           return malloc_impl(num, file, line);
  125.   
  126.       if (num <= 0)
                 ^
  127.           return NULL;
  128.   

crypto/mem.c:129:5: 
  127.           return NULL;
  128.   
  129. >     allow_customize = 0;
  130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
  137.       }
  138.   #else
  139. >     (void)file;
  140.       (void)line;
  141.       ret = malloc(num);

crypto/mem.c:140:5: 
  138.   #else
  139.       (void)file;
  140. >     (void)line;
  141.       ret = malloc(num);
  142.   #endif

crypto/mem.c:141:5: 
  139.       (void)file;
  140.       (void)line;
  141. >     ret = malloc(num);
  142.   #endif
  143.   

crypto/mem.c:156:5: 
  154.   #endif
  155.   
  156. >     return ret;
  157.   }
  158.   

crypto/mem.c:157:1: return from a call to CRYPTO_malloc
  155.   
  156.       return ret;
  157. > }
  158.   
  159.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/x509/by_dir.c:234:17: Taking false branch
232.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
233.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
234.               if (ent->dir == NULL || ent->hashes == NULL) {
                       ^
235.                   by_dir_entry_free(ent);
236.                   return 0;

crypto/x509/by_dir.c:234:37: Taking true branch
232.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
233.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
234.               if (ent->dir == NULL || ent->hashes == NULL) {
                                           ^
235.                   by_dir_entry_free(ent);
236.                   return 0;

crypto/x509/by_dir.c:235:17: 
233.               ent->dir = OPENSSL_malloc((unsigned int)len + 1);
234.               if (ent->dir == NULL || ent->hashes == NULL) {
235. >                 by_dir_entry_free(ent);
236.                   return 0;
237.               }

crypto/x509/by_dir.c:176:1: start of procedure by_dir_entry_free()
  174.   }
  175.   
  176. > static void by_dir_entry_free(BY_DIR_ENTRY *ent)
  177.   {
  178.       OPENSSL_free(ent->dir);

crypto/x509/by_dir.c:178:5: 
  176.   static void by_dir_entry_free(BY_DIR_ENTRY *ent)
  177.   {
  178. >     OPENSSL_free(ent->dir);
  179.       sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  180.       OPENSSL_free(ent);

crypto/mem.c:225:1: start of procedure CRYPTO_free()
    223.   }
    224.   
    225. > void CRYPTO_free(void *str, const char *file, int line)
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:227:9: Taking true branch
    225.   void CRYPTO_free(void *str, const char *file, int line)
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    228.           free_impl(str, file, line);
    229.           return;

crypto/mem.c:227:30: Taking true branch
    225.   void CRYPTO_free(void *str, const char *file, int line)
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    228.           free_impl(str, file, line);
    229.           return;

crypto/mem.c:228:9: Skipping __function_pointer__(): unresolved function pointer
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    228.           free_impl(str, file, line);
                   ^
    229.           return;
    230.       }

crypto/mem.c:229:9: 
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    228.           free_impl(str, file, line);
    229. >         return;
    230.       }
    231.   

crypto/mem.c:243:1: return from a call to CRYPTO_free
    241.       free(str);
    242.   #endif
    243. > }
    244.   
    245.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/by_dir.c:179:5: 
  177.   {
  178.       OPENSSL_free(ent->dir);
  179. >     sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  180.       OPENSSL_free(ent);
  181.   }

crypto/x509/x509_lcl.h:118:1: start of procedure sk_BY_DIR_HASH_pop_free()
    116.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
    117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
    118. > DEFINE_STACK_OF(BY_DIR_HASH)
    119.   DEFINE_STACK_OF(BY_DIR_ENTRY)
    120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/x509_lcl.h:118:1: return from a call to sk_BY_DIR_HASH_pop_free
    116.   typedef struct lookup_dir_hashes_st BY_DIR_HASH;
    117.   typedef struct lookup_dir_entry_st BY_DIR_ENTRY;
    118. > DEFINE_STACK_OF(BY_DIR_HASH)
    119.   DEFINE_STACK_OF(BY_DIR_ENTRY)
    120.   typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;

crypto/x509/by_dir.c:180:5: 
  178.       OPENSSL_free(ent->dir);
  179.       sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  180. >     OPENSSL_free(ent);
  181.   }
  182.   

crypto/mem.c:225:1: start of procedure CRYPTO_free()
    223.   }
    224.   
    225. > void CRYPTO_free(void *str, const char *file, int line)
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:227:9: Taking false branch
    225.   void CRYPTO_free(void *str, const char *file, int line)
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    228.           free_impl(str, file, line);
    229.           return;

crypto/mem.c:241:5: 
    239.       }
    240.   #else
    241. >     free(str);
    242.   #endif
    243.   }

crypto/mem.c:243:1: return from a call to CRYPTO_free
    241.       free(str);
    242.   #endif
    243. > }
    244.   
    245.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/by_dir.c:181:1: return from a call to by_dir_entry_free
  179.       sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
  180.       OPENSSL_free(ent);
  181. > }
  182.   
  183.   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 sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', '_STACK *sk_new_null(void)\n{\n    return sk_new((int (*)(const void *, const void *))0);\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    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;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\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}']