Skip to content

Commit

Permalink
Fix an error when writing an empty file
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTodorovskiIBM committed Sep 20, 2024
1 parent 8726f7a commit d541a3f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dio.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static enum DIOERR write_dataset_internal(struct DFILE* dfile)

errno = 0;

if ((dfile->bufflen == 0) || (dfile->buffer == NULL)) {
if ((dfile->bufflen < 0) || (dfile->buffer == NULL)) {
errmsg(dfile, "No buffer and/or buffer length not positive - no action performed.");
return DIOERR_INVALID_BUFFER_PASSED_TO_WRITE;
}
Expand Down Expand Up @@ -996,7 +996,7 @@ char *read_temp_file_to_buffer(char *tempname, struct DFILE *dfile) {
}

// Count lines to estimate buffer size
int lines = 0;
int lines = 1; // always start with one line
char *line = malloc(DS_MAX_REC_SIZE);

int prevMode = __ae_thread_swapmode(__AE_EBCDIC_MODE);
Expand Down

0 comments on commit d541a3f

Please sign in to comment.