Fix a segfault in query. Use strdupped cmd all the way