Просмотр исходного кода

dpkg: Destroy the dpkg_error variables on warnings

The leak on cmpversions() does not pose any issue on normal operation as
the program will exit immediately and the memory will be freed by the
system, but once --command-fd is enabled, it could actually be a problem
due to a long running dpkg process leaking repeatedly.

The leak on parse_db_version() is actually problematic as it can act
repeatedly if there's tons of warnings when parsing.

Regression introduced in commit ccc26399f2f0e295da1206c5ce81fe81a5dc0e21.

Reported-by: Niels Thykier <niels@thykier.net>
Guillem Jover лет назад: 15
Родитель
Сommit
5fc9084fd7
2 измененных файлов с 4 добавлено и 0 удалено
  1. 2 0
      lib/dpkg/parsehelp.c
  2. 2 0
      src/enquiry.c

+ 2 - 0
lib/dpkg/parsehelp.c

@@ -287,6 +287,8 @@ parse_db_version(struct parsedb_state *ps, struct versionrevision *version,
     parse_warn(ps, "%s: %.250s", buf, err.str);
   else
     parse_error(ps, "%s: %.250s", buf, err.str);
+
+  dpkg_error_destroy(&err);
 }
 
 void

+ 2 - 0
src/enquiry.c

@@ -529,6 +529,7 @@ cmpversions(const char *const *argv)
         warning(_("version '%s' has bad syntax: %s"), argv[0], err.str);
       else
         ohshit(_("version '%s' has bad syntax: %s"), argv[0], err.str);
+      dpkg_error_destroy(&err);
     }
   } else {
     blankversion(&a);
@@ -539,6 +540,7 @@ cmpversions(const char *const *argv)
         warning(_("version '%s' has bad syntax: %s"), argv[2], err.str);
       else
         ohshit(_("version '%s' has bad syntax: %s"), argv[2], err.str);
+      dpkg_error_destroy(&err);
     }
   } else {
     blankversion(&b);