diff --git a/doc/html/changelog.html b/doc/html/changelog.html
index 492ef9f7..ccf4357b 100644
--- a/doc/html/changelog.html
+++ b/doc/html/changelog.html
@@ -80,6 +80,7 @@
flac:
- Added a new option --no-utf8-convert which works like it does in metaflac (SF #973740).
+ - Fixed bug where using --replay-gain without any padding option caused only a small PADDING block to be created (SF #1760790).
diff --git a/src/flac/main.c b/src/flac/main.c
index 9b200d3a..53ea96e8 100644
--- a/src/flac/main.c
+++ b/src/flac/main.c
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
#if !defined _MSC_VER && !defined __MINGW32__
/* unlink is in stdio.h in VC++ */
@@ -432,7 +433,10 @@ int do_it(void)
* tags that we will set later, to avoid rewriting the
* whole file.
*/
- if(option_values.padding <= 0) {
+ if(
+ (option_values.padding >= 0 && option_values.padding < GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED) ||
+ (option_values.padding < 0 && FLAC_ENCODE__DEFAULT_PADDING < GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED)
+ ) {
flac__utils_printf(stderr, 1, "NOTE: --replay-gain may leave a small PADDING block even with --no-padding\n");
option_values.padding = GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED;
}