TT#111150 use intermediate variable for ftell()

This function returns -1 as error value, which would be lost if
immediately assigned to an unsigned type.

Change-Id: If9050b793519a529df671527c3a3e33ca2afc1bd
pull/1262/head
Richard Fuchs 5 years ago
parent 2dee5807e8
commit dcad209967

@ -385,14 +385,15 @@ void db_close_stream(output_t *op) {
return;
}
fseek(f, 0, SEEK_END);
stream.len = ftell(f);
if (stream.len < 0) {
long pos = ftell(f);
if (pos < 0) {
ilog(LOG_ERR, "Failed to get file position: %s", strerror(errno));
fclose(f);
if ((output_storage & OUTPUT_STORAGE_FILE))
goto file;
return;
}
stream.len = pos;
fseek(f, 0, SEEK_SET);
stream.s = malloc(stream.len);
if (stream.s) {

Loading…
Cancel
Save