diff options
author | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-15 00:13:40 (EST) |
---|---|---|
committer | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-15 00:13:40 (EST) |
commit | 6c77121fba6a9ca68e8a8ad39405542940999d15 (patch) | |
tree | 3ff795e732fe42bcbe14963b4f676a1f42a34e91 | |
parent | 9bb14a029601ad267a568d425181dbd44d0b2e3f (diff) |
opkg: prevent segfault if option is not found
git-svn-id: http://opkg.googlecode.com/svn/trunk@93 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r-- | libopkg/opkg.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libopkg/opkg.c b/libopkg/opkg.c index a749bf9..b94ad55 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -295,7 +295,7 @@ opkg_get_option (opkg_t *opkg, char *option, void **value) void opkg_set_option (opkg_t *opkg, char *option, void *value) { - int i = 0; + int i = 0, found = 0; opkg_option_t *options; opkg_assert (opkg != NULL); @@ -311,11 +311,18 @@ opkg_set_option (opkg_t *opkg, char *option, void *value) { if (strcmp (options[i].name, option) == 0) { + found = 1; break; } i++; } + if (!found) + { + /* XXX: Warning: Option not found */ + return; + } + /* set the option */ switch (options[i].type) { |