diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 63bf7e96a5..2ca91bea8b 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -956,7 +956,11 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
             xmlFree(val);
         }
         if (adaptionset_supplementalproperty_node) {
-            if (!av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,"schemeIdUri"), "http://dashif.org/guidelines/last-segment-number")) {
+            char *scheme_id_uri = xmlGetProp(adaptionset_supplementalproperty_node, "schemeIdUri");
+            if (scheme_id_uri) {
+                int is_last_segment_number = !av_strcasecmp(scheme_id_uri, "http://dashif.org/guidelines/last-segment-number");
+                xmlFree(scheme_id_uri);
+                if (is_last_segment_number) {
                 val = xmlGetProp(adaptionset_supplementalproperty_node,"value");
                 if (!val) {
                     av_log(s, AV_LOG_ERROR, "Missing value attribute in adaptionset_supplementalproperty_node\n");
@@ -965,6 +969,7 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url,
                     xmlFree(val);
                 }
             }
+            }
         }
 
         fragment_timeline_node = find_child_node_by_name(representation_segmenttemplate_node, "SegmentTimeline");