diff --git a/configure b/configure
index 01f9238986f4b41c3b8dbee833a9f6c6233d9935..efd2b72f65badd28b93473faaa81522dca672028 100755
--- a/configure
+++ b/configure
@@ -2874,7 +2874,7 @@ for thread in $THREADS_LIST; do
     fi
 done
 
-check_lib math.h sin -lm
+check_lib math.h sin -lm && LIBM="-lm"
 disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd
 enabled vaapi && require vaapi va/va.h vaInitialize -lva
 
@@ -3485,10 +3485,10 @@ Cflags: -I\${includedir}
 EOF
 }
 
-pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
-pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs"
+pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBM"
+pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs $LIBM" "libavutil = $LIBAVUTIL_VERSION"
 pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
 pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
-pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
-pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
+pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
+pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 5ed36319503aa3916e7088dcc37806a6ff1acb88..eacfa5f6a4bfa92b89974596a277cf99c0057a0f 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -539,7 +539,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
             rangemax = (1 << rangebits);
             if (rangemax > vc->blocksize[1] / 2) {
                 av_log(vc->avccontext, AV_LOG_ERROR,
-                       "Floor value is too large for blocksize: %d (%d)\n",
+                       "Floor value is too large for blocksize: %"PRIuFAST32" (%"PRIuFAST32")\n",
                        rangemax, vc->blocksize[1] / 2);
                 return -1;
             }
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 93d4f732957875ce36ba6a7530f664763f14bffc..4429ad01990e5ea4c17cb3ba94e95ed54d683443 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -505,7 +505,9 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
                 goto fail;
             }
             avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
-            av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str, 0);
+            if (v->bandwidth)
+                av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str,
+                                 0);
         }
         stream_offset += v->ctx->nb_streams;
     }
diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index ea6012ad09fc9eff5c542c954a5575f91435f3f2..fecc2c961c2434d4239ea0533462eef18d7b7d1e 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -153,9 +153,9 @@ static int crypto_close(URLContext *h)
     CryptoContext *c = h->priv_data;
     if (c->hd)
         ffurl_close(c->hd);
-    av_free(c->aes);
-    av_free(c->key);
-    av_free(c->iv);
+    av_freep(&c->aes);
+    av_freep(&c->key);
+    av_freep(&c->iv);
     return 0;
 }
 
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 2f76ec8871d33f914f50890311aa4a34f96c4abc..29e4907e86decd7dd6ae981e25c38dba8c7d63c5 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -243,14 +243,14 @@ ogg_read_page (AVFormatContext * s, int *str)
     idx = ogg_find_stream (ogg, serial);
     if (idx < 0){
         if (ogg->headers) {
-                int n;
+            int n;
 
-                for (n = 0; n < ogg->nstreams; n++) {
-                    av_freep(&ogg->streams[n].buf);
-                    av_freep(&ogg->streams[n].private);
-                }
-                ogg->curidx   = -1;
-                ogg->nstreams = 0;
+            for (n = 0; n < ogg->nstreams; n++) {
+                av_freep(&ogg->streams[n].buf);
+                av_freep(&ogg->streams[n].private);
+            }
+            ogg->curidx   = -1;
+            ogg->nstreams = 0;
         }
         idx = ogg_new_stream (s, serial);
         if (idx < 0)