mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-28 01:41:48 +03:00
examples: Check for null earlier
Thanks coverity CID 1461476 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
This commit is contained in:
@ -229,11 +229,11 @@ static int open_location(struct location *loc, int flag) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
} else if (loc->path != NULL) {
|
||||
loc->file = fopen(loc->path, flag == READ ? "r":"w");
|
||||
if (!loc->file) {
|
||||
if (errno == EISDIR) {
|
||||
if (loc->path != NULL && chdir(loc->path)) {
|
||||
if (chdir(loc->path)) {
|
||||
fprintf(stderr,
|
||||
"Error changing directory to %s: %s\n",
|
||||
loc->path, strerror(errno));
|
||||
|
Reference in New Issue
Block a user