Author: hartmannathan
Date: Tue Jun  4 01:41:36 2024
New Revision: 1918138

URL: http://svn.apache.org/viewvc?rev=1918138&view=rev
Log:
Fix unbounded memory usage in `svn propget` command.

* subversion/svn/propget-cmd.c
  (print_properties): Invoke svn_pool_clear() inside the loop to clean the
   iterpool properly and refactor this part of the code to make it more
   readable.

See dev@ message on 30 May 2024:
"[PATCH] Fix unbounded memory usage in `svn propget` command."
archived:
https://lists.apache.org/thread/l4l13jhv74pkzptrgx0fwmycxs9oob8v

Patch by: Timofey Zhakov (tima {at} chemodax _dot_ net)

Review by: hartmannathan

Modified:
    subversion/trunk/subversion/svn/propget-cmd.c

Modified: subversion/trunk/subversion/svn/propget-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/propget-cmd.c?rev=1918138&r1=1918137&r2=1918138&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/propget-cmd.c (original)
+++ subversion/trunk/subversion/svn/propget-cmd.c Tue Jun  4 01:41:36 2024
@@ -272,14 +272,18 @@ print_properties(svn_stream_t *out,
 
   if (inherited_props)
     {
-      svn_pool_clear(iterpool);
-
       for (i = 0; i < inherited_props->nelts; i++)
         {
-          svn_prop_inherited_item_t *iprop =
-            APR_ARRAY_IDX(inherited_props, i, svn_prop_inherited_item_t *);
-          svn_string_t *propval = apr_hash_this_val(apr_hash_first(pool,
-                                                          iprop->prop_hash));
+          svn_prop_inherited_item_t *iprop;
+          svn_string_t *propval;
+
+          svn_pool_clear(iterpool);
+
+          iprop = APR_ARRAY_IDX(inherited_props, i,
+                                svn_prop_inherited_item_t *);
+          propval = apr_hash_this_val(apr_hash_first(iterpool,
+                                                     iprop->prop_hash));
+
           SVN_ERR(print_single_prop(propval, target_abspath_or_url,
                                     iprop->path_or_url,
                                     path_prefix, out, pname,


Reply via email to