diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-05-18 17:39:05 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-05-18 17:39:05 +0200 |
commit | d50845646087c15dd68e24b8504f138869c3e7f2 (patch) | |
tree | b1a1738df9dbd59de549f364e90d26e8ef02a1dc | |
parent | 6c207f6c266759c2ab0284054045ae062fd6664b (diff) | |
download | ipecamera-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.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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); |