diff --git a/agent/mibgroup/host/data_access/swinst_rpm.c b/agent/mibgroup/host/data_access/swinst_rpm.c
index 695c469..dd0e487 100644
--- a/agent/mibgroup/host/data_access/swinst_rpm.c
+++ b/agent/mibgroup/host/data_access/swinst_rpm.c
@@ -75,6 +75,9 @@ netsnmp_swinst_arch_init(void)
     snprintf( pkg_directory, SNMP_MAXPATH, "%s/Packages", dbpath );
     SNMP_FREE(rpmdbpath);
     dbpath = NULL;
+#ifdef HAVE_RPMGETPATH
+    rpmFreeRpmrc();
+#endif
     if (-1 == stat( pkg_directory, &stat_buf )) {
         snmp_log(LOG_ERR, "Can't find directory of RPM packages\n");
         pkg_directory[0] = '\0';
diff --git a/agent/mibgroup/host/hr_swinst.c b/agent/mibgroup/host/hr_swinst.c
index 1f52733..ccf1cab 100644
--- a/agent/mibgroup/host/hr_swinst.c
+++ b/agent/mibgroup/host/hr_swinst.c
@@ -231,6 +231,9 @@ init_hr_swinst(void)
             snprintf(path, sizeof(path), "%s/packages.rpm", swi->swi_dbpath);
         path[ sizeof(path)-1 ] = 0;
         swi->swi_directory = strdup(path);
+#ifdef HAVE_RPMGETPATH
+        rpmFreeRpmrc();
+#endif
     }
 #else
 #  ifdef _PATH_HRSW_directory


