[PATCH] Correctly initialize modopts in loader (#531932).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Under certain conditions, modopts is never initialized.  This patch
fixes up that while preserving the existing functionality introduced
with 29e18c35.
---
 loader/modules.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/loader/modules.c b/loader/modules.c
index d5129b7..f61f680 100644
--- a/loader/modules.c
+++ b/loader/modules.c
@@ -117,16 +117,18 @@ static void addOption(const char *module, const char *option) {
     }
 
     if (found) {
-        modopts[i].options = realloc(modopts[i].options,
-                                     sizeof(modopts[i].options) *
-                                     (modopts[i].numopts + 1));
-        modopts[i].options[modopts[i].numopts - 1] = strdup(option);
-        modopts[i].options[modopts[i].numopts] = NULL;
-    } else {
-        modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
-        modopts[nummodopts].name = strdup(module);
-        modopts[nummodopts].numopts = 1;
-        modopts[nummodopts++].options = NULL;
+        if (modopts == NULL) {
+            modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
+            modopts[nummodopts].name = strdup(module);
+            modopts[nummodopts].numopts = 1;
+            modopts[nummodopts++].options = NULL;
+        } else {
+            modopts[i].options = realloc(modopts[i].options,
+                                         sizeof(modopts[i].options) *
+                                         (modopts[i].numopts + 1));
+            modopts[i].options[modopts[i].numopts - 1] = strdup(option);
+            modopts[i].options[modopts[i].numopts] = NULL;
+        }
     }
 
     return;
-- 
1.6.5.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux