On 11/04/2009 11:27 PM, David Cantrell wrote:
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;
Hi again David,
I was looking at this issue yesterday and I just took a look at your
patch. I am a bit confused: The code in the new revision will do nothing
in case a module of given name is not found in the table. If we assume
that nummodopts is initially 0, nothing ever gets added and the table
will remain empty -- is that what we want?
Also: why nummodopts is initially -1 (that has nothing to do with your
patch though, just a question)? Is that because we don't want
mlLoadModule calls to modify the table before mlInitModuleConfig is called?
Thank you,
Ales
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list