Uploaded image for project: 'Subversion'
  1. Subversion
  2. SVN-4907

svn_fs_node_id causes memory leak...

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Not A Problem
    • 1.10.x
    • None
    • svnlook
    • None

    Description

      We used svnlook to transform a dynamic library for some of our interface operations. We found that memory leaks would occur when svn_fs_node_id (with apr_pool_t  and svn_pool_destroy(pool)) was called frequently;

      The code looks shown below, we call svn_fs_node_id with apr_pool_t , and after the call , we use svn_pool_destroy(pool) clear memory. But there is a bug : if we  use a nonexistent path call subcommand_show_revison, the  memory will leak ; but if a existing path, the memory is ok, no memory leak .

       

      int init_svncmcenter(apr_pool_t *pool,char *out_str,const char *repos_path,const char *path,const char **path_relative,const char *rev,struct svnlook_opt_state *opt_state,svn_fs_root_t **root,const svn_fs_id_t **id,svnlook_ctxt_t * *c,int with_lastexist )
      {
        ......
        ......
        if ((svn_fs_node_id(id, *root, *path_relative, pool)) != SVN_NO_ERROR || !(*id))

       

      {

      //memory leak happens here

           printf("path (%s) error. Warning: svn_fs_node_id may cause memory leaks.\n", path);      sprintf(out_str,"212 path error");      return 212;    }

         return 200;
      }

      int subcommand_show_revison(const char *repos_path,const char *path,const char *rev,char *out_str,int b_filesize,int with_changed_date,int with_author)
      {
        apr_pool_t *pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
        ......
        ......
        if (init_svncmcenter(pool,out_str, repos_path, path,&path_relative,rev,&opt_state,&root,&id,&c,1) != 200)
        {
        svn_pool_destroy(pool);

        return -1;
        }
        ......
        ......
        svn_pool_destroy(pool);
        return 0;
      }

      Attachments

        1. svntest.c
          9 kB
          Nathan.qian

        Activity

          People

            Unassigned Unassigned
            Nathan.Qian Nathan.qian
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: