Skip to content

Commit 107f228

Browse files
committed
Fix CICD build test failure.
Signed-off-by: Michael Keller <github@ike.ch>
1 parent 4333211 commit 107f228

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/garmin.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ get_file_list(dc_device_t *abstract, const char *pathname, struct file_list *fil
333333
add_name(files, findData.cFileName, 0);
334334
} while (FindNextFileA(hFind, &findData));
335335

336+
if (GetLastError() != ERROR_NO_MORE_FILES) {
337+
FindClose(hFind);
338+
return DC_STATUS_IO;
339+
}
340+
336341
FindClose(hFind);
337342

338343
DEBUG(abstract->context, "Found %d files", files->nr);
@@ -596,12 +601,22 @@ garmin_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void
596601
// On Windows, get_file_list takes the pathname directly
597602
rc = get_file_list(abstract, pathname, &files);
598603
if (rc != DC_STATUS_SUCCESS) {
604+
if (rc == DC_STATUS_NOMEMORY) {
605+
free(files.array);
606+
return rc;
607+
}
608+
609+
free(files.array);
610+
files.nr = 0;
611+
files.allocated = 0;
612+
files.array = NULL;
613+
599614
// Try the input path directly
600615
rc = get_file_list(abstract, pathname_input, &files);
601616
if (rc != DC_STATUS_SUCCESS) {
602617
ERROR (abstract->context, "Failed to open directory '%s' or '%s'.", pathname, pathname_input);
603618
free(files.array);
604-
return DC_STATUS_IO;
619+
return rc;
605620
}
606621
strcpy(pathname, pathname_input);
607622
pathlen = strlen(pathname);

src/platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern "C" {
4848
#ifdef _MSC_VER
4949
#define strcasecmp _stricmp
5050
#define strncasecmp _strnicmp
51+
#define strdup _strdup
5152
#if _MSC_VER < 1800
5253
// The rint() function is only available in MSVC 2013 and later
5354
// versions. Our replacement macro isn't entirely correct, because the

0 commit comments

Comments
 (0)