[PATCH 2/4] Do not assume we found a module in addOption() in loader/modules.c

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

 



Avoid SIGSEGV in addOption() in loader/modules.c.  Just because found
does not equal 0 does not mean we found the module requested.
---
 loader/modules.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/loader/modules.c b/loader/modules.c
index bddda2b..d5129b7 100644
--- a/loader/modules.c
+++ b/loader/modules.c
@@ -115,17 +115,21 @@ static void addOption(const char *module, const char *option) {
         found = 1;
         break;
     }
-    if (found == 0) {
+
+    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;
     }
-    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;
 }
 
 static int isValidModule(char *module) {
-- 
1.6.2.5

_______________________________________________
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