diff mbox series

[FFmpeg-devel,1/2] avformat/aadec: Use smaller scope for variables, remove initializations

Message ID 20210302091657.473380-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 80038fd524cbed9fda1c8db2e2f4436622de9706
Headers show
Series [FFmpeg-devel,1/2] avformat/aadec: Use smaller scope for variables, remove initializations | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 2, 2021, 9:16 a.m. UTC
avio_get_str always zero terminates the strings it reads.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/aadec.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Andreas Rheinhardt March 4, 2021, 1:21 p.m. UTC | #1
Andreas Rheinhardt:
> avio_get_str always zero terminates the strings it reads.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/aadec.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/aadec.c b/libavformat/aadec.c
> index 612e66906d..b1e93ea072 100644
> --- a/libavformat/aadec.c
> +++ b/libavformat/aadec.c
> @@ -72,8 +72,8 @@ static int get_second_size(char *codec_name)
>  static int aa_read_header(AVFormatContext *s)
>  {
>      int i, j, idx, largest_idx = -1;
> -    uint32_t nkey, nval, toc_size, npairs, header_seed = 0, start;
> -    char key[128], val[128], codec_name[64] = {0};
> +    uint32_t toc_size, npairs, header_seed = 0, start;
> +    char codec_name[64] = {0};
>      uint8_t output[24], dst[8], src[8];
>      int64_t largest_size = -1, current_size = -1, chapter_pos;
>      struct toc_entry {
> @@ -104,8 +104,9 @@ static int aa_read_header(AVFormatContext *s)
>      if (npairs > MAX_DICTIONARY_ENTRIES)
>          return AVERROR_INVALIDDATA;
>      for (i = 0; i < npairs; i++) {
> -        memset(val, 0, sizeof(val));
> -        memset(key, 0, sizeof(key));
> +        char key[128], val[128];
> +        uint32_t nkey, nval;
> +
>          avio_skip(pb, 1); // unidentified integer
>          nkey = avio_rb32(pb); // key string length
>          nval = avio_rb32(pb); // value string length
> 
Will apply this patchset tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 612e66906d..b1e93ea072 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -72,8 +72,8 @@  static int get_second_size(char *codec_name)
 static int aa_read_header(AVFormatContext *s)
 {
     int i, j, idx, largest_idx = -1;
-    uint32_t nkey, nval, toc_size, npairs, header_seed = 0, start;
-    char key[128], val[128], codec_name[64] = {0};
+    uint32_t toc_size, npairs, header_seed = 0, start;
+    char codec_name[64] = {0};
     uint8_t output[24], dst[8], src[8];
     int64_t largest_size = -1, current_size = -1, chapter_pos;
     struct toc_entry {
@@ -104,8 +104,9 @@  static int aa_read_header(AVFormatContext *s)
     if (npairs > MAX_DICTIONARY_ENTRIES)
         return AVERROR_INVALIDDATA;
     for (i = 0; i < npairs; i++) {
-        memset(val, 0, sizeof(val));
-        memset(key, 0, sizeof(key));
+        char key[128], val[128];
+        uint32_t nkey, nval;
+
         avio_skip(pb, 1); // unidentified integer
         nkey = avio_rb32(pb); // key string length
         nval = avio_rb32(pb); // value string length