diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wsman.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/wsman.c b/src/wsman.c index 51bafb6..75f0c4a 100644 --- a/src/wsman.c +++ b/src/wsman.c @@ -443,15 +443,20 @@ static void wsman_output(WsManClient * cl, WsXmlDocH doc) */ static void wsman_output_pull(WsManClient * cl, WsXmlDocH doc, int index) { - char *strbuf, *origfile = output_file; - int count = strlen(output_file) + 16; - - strbuf = (char*)calloc(count, 1); - snprintf(strbuf, count, "%s-%u.xml", output_file, index); - output_file = strbuf; - wsman_output(cl, doc); - output_file = origfile; - free(strbuf); + char *strbuf, *origfile = output_file; + int count; + + if (output_file) { + count = strlen(output_file) + 16; + strbuf = (char*)calloc(count, 1); + snprintf(strbuf, count, "%s-%u.xml", output_file, index); + output_file = strbuf; + } + wsman_output(cl, doc); + if (origfile) { + output_file = origfile; + free(strbuf); + } } static void initialize_logging(void) |