1
0
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:
Jakub Jelen
2023-06-28 12:22:51 +02:00
parent f8a7571a91
commit 55cabab847

View File

@ -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));