crypto/x509/by_dir.c:194: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_strndup()` at line 192, column 24 is not reachable after line 194, column 17.
Showing all 96 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.       const char *s, *p;

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

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

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

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

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

crypto/x509/by_dir.c:167:13: 
165.               int j;
166.               size_t len;
167. >             const char *ss = s;
168.               s = p + 1;
169.               len = p - ss;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/x509/by_dir.c:190:13: 
188.               if (ent == NULL)
189.                   return 0;
190. >             ent->dir_type = type;
191.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
192.               ent->dir = OPENSSL_strndup(ss, len);

crypto/x509/by_dir.c:191:13: 
189.                   return 0;
190.               ent->dir_type = type;
191. >             ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
192.               ent->dir = OPENSSL_strndup(ss, len);
193.               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:192:13: 
190.               ent->dir_type = type;
191.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
192. >             ent->dir = OPENSSL_strndup(ss, len);
193.               if (ent->dir == NULL || ent->hashes == NULL) {
194.                   by_dir_entry_free(ent);

crypto/o_str.c:41:1: start of procedure CRYPTO_strndup()
  39.   }
  40.   
  41. > char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)
  42.   {
  43.       size_t maxlen;

crypto/o_str.c:46:9: Taking false branch
  44.       char *ret;
  45.   
  46.       if (str == NULL)
                ^
  47.           return NULL;
  48.   

crypto/o_str.c:49:5: 
  47.           return NULL;
  48.   
  49. >     maxlen = OPENSSL_strnlen(str, s);
  50.   
  51.       ret = CRYPTO_malloc(maxlen + 1, file, line);

crypto/o_str.c:74:1: start of procedure OPENSSL_strnlen()
    72.   }
    73.   
    74. > size_t OPENSSL_strnlen(const char *str, size_t maxlen)
    75.   {
    76.       const char *p;

crypto/o_str.c:78:10: 
    76.       const char *p;
    77.   
    78. >     for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
    79.   
    80.       return p - str;

crypto/o_str.c:78:19: Loop condition is true. Entering loop body
    76.       const char *p;
    77.   
    78.       for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
                            ^
    79.   
    80.       return p - str;

crypto/o_str.c:78:36: Loop condition is true. Entering loop body
    76.       const char *p;
    77.   
    78.       for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
                                             ^
    79.   
    80.       return p - str;

crypto/o_str.c:78:48: 
    76.       const char *p;
    77.   
    78. >     for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
    79.   
    80.       return p - str;

crypto/o_str.c:78:19: Loop condition is true. Entering loop body
    76.       const char *p;
    77.   
    78.       for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
                            ^
    79.   
    80.       return p - str;

crypto/o_str.c:78:36: Loop condition is false. Leaving loop
    76.       const char *p;
    77.   
    78.       for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
                                             ^
    79.   
    80.       return p - str;

crypto/o_str.c:80:5: 
    78.       for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
    79.   
    80. >     return p - str;
    81.   }
    82.   

crypto/o_str.c:81:1: return from a call to OPENSSL_strnlen
    79.   
    80.       return p - str;
    81. > }
    82.   
    83.   size_t OPENSSL_strlcpy(char *dst, const char *src, size_t size)

crypto/o_str.c:51:5: 
  49.       maxlen = OPENSSL_strnlen(str, s);
  50.   
  51. >     ret = CRYPTO_malloc(maxlen + 1, file, line);
  52.       if (ret) {
  53.           memcpy(ret, str, maxlen);

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

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

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

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

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

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

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

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

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

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

crypto/o_str.c:52:9: Taking true branch
  50.   
  51.       ret = CRYPTO_malloc(maxlen + 1, file, line);
  52.       if (ret) {
                ^
  53.           memcpy(ret, str, maxlen);
  54.           ret[maxlen] = '\0';

crypto/o_str.c:53:9: 
  51.       ret = CRYPTO_malloc(maxlen + 1, file, line);
  52.       if (ret) {
  53. >         memcpy(ret, str, maxlen);
  54.           ret[maxlen] = '\0';
  55.       }

crypto/o_str.c:54:9: 
  52.       if (ret) {
  53.           memcpy(ret, str, maxlen);
  54. >         ret[maxlen] = '\0';
  55.       }
  56.       return ret;

crypto/o_str.c:56:5: 
  54.           ret[maxlen] = '\0';
  55.       }
  56. >     return ret;
  57.   }
  58.   

crypto/o_str.c:57:1: return from a call to CRYPTO_strndup
  55.       }
  56.       return ret;
  57. > }
  58.   
  59.   void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line)

crypto/x509/by_dir.c:193:17: Taking false branch
191.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
192.               ent->dir = OPENSSL_strndup(ss, len);
193.               if (ent->dir == NULL || ent->hashes == NULL) {
                       ^
194.                   by_dir_entry_free(ent);
195.                   return 0;

crypto/x509/by_dir.c:193:37: Taking true branch
191.               ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
192.               ent->dir = OPENSSL_strndup(ss, len);
193.               if (ent->dir == NULL || ent->hashes == NULL) {
                                           ^
194.                   by_dir_entry_free(ent);
195.                   return 0;

crypto/x509/by_dir.c:194:17: 
192.               ent->dir = OPENSSL_strndup(ss, len);
193.               if (ent->dir == NULL || ent->hashes == NULL) {
194. >                 by_dir_entry_free(ent);
195.                   return 0;
196.               }

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:264:1: start of procedure CRYPTO_free()
    262.   }
    263.   
    264. > void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

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

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

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

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

crypto/mem.c:282:1: return from a call to CRYPTO_free
    280.       free(str);
    281.   #endif
    282. > }
    283.   
    284.   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:264:1: start of procedure CRYPTO_free()
    262.   }
    263.   
    264. > void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

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

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

crypto/mem.c:282:1: return from a call to CRYPTO_free
    280.       free(str);
    281.   #endif
    282. > }
    283.   
    284.   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)
{
    const char *s, *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;
            int j;
            size_t len;
            const char *ss = s;
            s = p + 1;
            len = 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) == len &&
                    strncmp(ent->dir, ss, 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_strndup(ss, len);
            if (ent->dir == NULL || ent->hashes == NULL) {
                by_dir_entry_free(ent);
                return 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    const char *s, *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            int j;\n            size_t len;\n            const char *ss = s;\n            s = p + 1;\n            len = 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) == len &&\n                    strncmp(ent->dir, ss, 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_strndup(ss, len);\n            if (ent->dir == NULL || ent->hashes == NULL) {\n                by_dir_entry_free(ent);\n                return 0;\n            }\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}', "char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)\n{\n    size_t maxlen;\n    char *ret;\n    if (str == NULL)\n        return NULL;\n    maxlen = OPENSSL_strnlen(str, s);\n    ret = CRYPTO_malloc(maxlen + 1, file, line);\n    if (ret) {\n        memcpy(ret, str, maxlen);\n        ret[maxlen] = '\\0';\n    }\n    return ret;\n}", "size_t OPENSSL_strnlen(const char *str, size_t maxlen)\n{\n    const char *p;\n    for (p = str; maxlen-- != 0 && *p != '\\0'; ++p) ;\n    return p - str;\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}']