summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-05-18 17:39:05 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-05-18 17:39:05 +0200
commitd50845646087c15dd68e24b8504f138869c3e7f2 (patch)
treeb1a1738df9dbd59de549f364e90d26e8ef02a1dc
parent6c207f6c266759c2ab0284054045ae062fd6664b (diff)
downloadipecamera-d50845646087c15dd68e24b8504f138869c3e7f2.tar.gz
ipecamera-d50845646087c15dd68e24b8504f138869c3e7f2.tar.bz2
ipecamera-d50845646087c15dd68e24b8504f138869c3e7f2.tar.xz
ipecamera-d50845646087c15dd68e24b8504f138869c3e7f2.zip
Do not crash if model is not defined
-rw-r--r--cli.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/cli.c b/cli.c
index b27ae64..860fd9e 100644
--- a/cli.c
+++ b/cli.c
@@ -782,12 +782,14 @@ int main(int argc, char **argv) {
if ((isxnumber(addr))&&(sscanf(addr, "%lx", &start) == 1)) {
// check if the address in the register range
pcilib_register_range_t *ranges = pcilib_model[model].ranges;
-
- for (i = 0; ranges[i].start != ranges[i].end; i++)
- if ((start >= ranges[i].start)&&(start <= ranges[i].end)) break;
-
- // register access in plain mode
- if (ranges[i].start != ranges[i].end) ++mode;
+
+ if (ranges) {
+ for (i = 0; ranges[i].start != ranges[i].end; i++)
+ if ((start >= ranges[i].start)&&(start <= ranges[i].end)) break;
+
+ // register access in plain mode
+ if (ranges[i].start != ranges[i].end) ++mode;
+ }
} else {
if (pcilib_find_register(handle, bank, addr) == PCILIB_REGISTER_INVALID) {
Usage(argc, argv, "Invalid address (%s) is specified", addr);