diff --git a/lib/init.c b/lib/init.c index d7d32d2..8c489a7 100644 --- a/lib/init.c +++ b/lib/init.c @@ -251,8 +251,13 @@ iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, ...) } va_end(ap); - strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE); - DPRINTF(iscsi,1,"%s",iscsi->error_string); + if (iscsi != NULL) { + strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE); + DPRINTF(iscsi,1,"%s",iscsi->error_string); + } + else { + fprintf(stderr,"libiscsi: %s\n", errstr); + } } void