fix size and number of items ordering in fread() to match returned sizes

This commit is contained in:
stefan schippers 2024-03-15 16:07:46 +01:00
parent 092f111925
commit f84305930f
2 changed files with 5 additions and 5 deletions

View File

@ -3997,7 +3997,7 @@ void draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, double *y2
if(fd) {
size_t bytes_read;
filedata = my_malloc(_ALLOC_ID_, filesize);
if((bytes_read = fread(filedata, filesize, 1, fd)) < filesize) {
if((bytes_read = fread(filedata, 1, filesize, fd)) < filesize) {
filesize = bytes_read;
dbg(0, "draw_image(): less bytes read than expected from %s, got %ld bytes\n", filename, bytes_read);
}
@ -4037,7 +4037,7 @@ void draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, double *y2
fd = fopen(filename, "r");
if(fd) {
size_t bytes_read;
if((bytes_read = fread(header, size, 1, fd)) < size) {
if((bytes_read = fread(header, 1, size, fd)) < size) {
size = bytes_read;
dbg(0, "draw_image(): less bytes read than expected from %s, got %ld bytes\n", filename, bytes_read);
}

View File

@ -417,7 +417,7 @@ static void read_binary_block(FILE *fd, Raw *raw, int ac)
npoints = 0;
filepos = xftell(fd); /* store file pointer position */
for(p = 0; p < raw->npoints[raw->datasets]; p++) {
if(fread(tmp, sizeof(double) , raw->nvars, fd) != raw->nvars) {
if(fread(tmp, sizeof(double), raw->nvars, fd) != raw->nvars) {
dbg(0, "Warning: binary block is not of correct size\n");
}
sweepvar = tmp[0];
@ -438,7 +438,7 @@ static void read_binary_block(FILE *fd, Raw *raw, int ac)
/* read binary block */
p = 0;
for(i = 0; i < raw->npoints[raw->datasets]; i++) {
if(fread(tmp, sizeof(double) , raw->nvars, fd) != raw->nvars) {
if(fread(tmp, sizeof(double), raw->nvars, fd) != raw->nvars) {
dbg(0, "Warning: binary block is not of correct size\n");
}
@ -777,7 +777,7 @@ char *base64_from_file(const char *f, size_t *length)
if(fd) {
size_t bytes_read;
s = my_malloc(_ALLOC_ID_, len);
if((bytes_read = fread(s, len, 1, fd)) < len) {
if((bytes_read = fread(s, 1, len, fd)) < len) {
dbg(0, "base64_from_file(): less bytes FROM %S, got %ld bytes\n", f, bytes_read);
}
fclose(fd);