pkgng/pkgng — Issue #107: pkg version -t crash
Author: novel
Created: 2011-10-08 05:07:03+00:00
State: open

'pkg version -t' coredumps for me like that:

```(gdb) r version -t gettext-0.18.1.1 gettext-0.18.1.1
Starting program: /usr/sbin/pkg version -t gettext-0.18.1.1 gettext-0.18.1.1
[New LWP 100075]
[New Thread 28804140 (LWP 100075)]
=

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 28804140 (LWP 100075)]
0x280c7c05 in pkgdb_it_free (it=0x0) at pkgdb.c:643
643 if (it->db->writable == 1) {
(gdb) bt
#0 0x280c7c05 in pkgdb_it_free (it=0x0) at pkgdb.c:643
#1 0x08052aa5 in exec_version (argc=2, argv=0xbfbfec1c) at version.c:307
#2 0x0804d680 in main (argc=4, argv=0xbfbfec14) at main.c:217
(gdb) print it
$1 = (struct pkgdb_it *) 0x0
(gdb) q```

It seems to happen because 'version -t' doesn't need to access database and 'it' is never defined in this case.

This change seems to fix problem for me: http://people.freebsd.org/~novel/misc/version-crash-pkgdb.c.diff