diff mbox

[FFmpeg-devel,2/2] avformat/fitsenc: fill header line with spaces

Message ID 1504379242-8281-2-git-send-email-paraschadha18@gmail.com
State New
Headers show

Commit Message

Paras Sept. 2, 2017, 7:07 p.m. UTC
Signed-off-by: Paras Chadha <paraschadha18@gmail.com>
---
This fixes the failed fate tests on msvc12:
http://fate.ffmpeg.org/report.cgi?time=20170901190511&slot=x86_32-msvc12-windows-native
http://fate.ffmpeg.org/report.cgi?time=20170901211336&slot=x86_64-msvc12-windows-native

Tests failed because snprintf was filling the buffer with '\0' chars
after printing.

 libavformat/fitsenc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.4.11

Comments

James Almer Sept. 13, 2017, 12:55 a.m. UTC | #1
On 9/2/2017 4:07 PM, Paras Chadha wrote:
> Signed-off-by: Paras Chadha <paraschadha18@gmail.com>
> ---
> This fixes the failed fate tests on msvc12:
> http://fate.ffmpeg.org/report.cgi?time=20170901190511&slot=x86_32-msvc12-windows-native
> http://fate.ffmpeg.org/report.cgi?time=20170901211336&slot=x86_64-msvc12-windows-native
> 
> Tests failed because snprintf was filling the buffer with '\0' chars
> after printing.
> 
>  libavformat/fitsenc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/fitsenc.c b/libavformat/fitsenc.c
> index 0dcdcdf..1a4b7c2 100644
> --- a/libavformat/fitsenc.c
> +++ b/libavformat/fitsenc.c
> @@ -47,7 +47,7 @@ static int fits_write_header(AVFormatContext *s)
>   */
>  static int write_keyword_value(AVFormatContext *s, const char *keyword, int value, int *lines_written)
>  {
> -    int len, ret;
> +    int len, ret, i;
>      uint8_t header[80];
> 
>      len = strlen(keyword);
> @@ -58,7 +58,9 @@ static int write_keyword_value(AVFormatContext *s, const char *keyword, int valu
>      header[9] = ' ';
> 
>      ret = snprintf(header + 10, 70, "%d", value);
> -    header[ret + 10] = ' ';
> +    for (i = ret + 10; i < 80; i++) {
> +        header[i] = ' ';
> +    }
> 
>      avio_write(s->pb, header, sizeof(header));
>      *lines_written += 1;

Simplified it a bit and pushed.

Thanks!
diff mbox

Patch

diff --git a/libavformat/fitsenc.c b/libavformat/fitsenc.c
index 0dcdcdf..1a4b7c2 100644
--- a/libavformat/fitsenc.c
+++ b/libavformat/fitsenc.c
@@ -47,7 +47,7 @@  static int fits_write_header(AVFormatContext *s)
  */
 static int write_keyword_value(AVFormatContext *s, const char *keyword, int value, int *lines_written)
 {
-    int len, ret;
+    int len, ret, i;
     uint8_t header[80];

     len = strlen(keyword);
@@ -58,7 +58,9 @@  static int write_keyword_value(AVFormatContext *s, const char *keyword, int valu
     header[9] = ' ';

     ret = snprintf(header + 10, 70, "%d", value);
-    header[ret + 10] = ' ';
+    for (i = ret + 10; i < 80; i++) {
+        header[i] = ' ';
+    }

     avio_write(s->pb, header, sizeof(header));
     *lines_written += 1;