Skip to content

Bug: updateSourceCaches_() assumes srcObj has src and type properties #9185

Description

@ai-bughunter

Bug: updateSourceCaches_() assumes srcObj has src and type properties

Severity: Low
Files: src/js/player.js
Lines: 1582-1585

Description

When srcObj is a non-string object, the code accesses srcObj.src and srcObj.type without checking if these properties exist. If srcObj is null, {}, or an object with different keys, src and type will be undefined, leading to silent failures.

Affected code

if (typeof src !== 'string') {
  src = srcObj.src;   // <-- Could be undefined
  type = srcObj.type; // <-- Could be undefined
}

Suggested fix

if (typeof src !== 'string') {
  src = srcObj?.src ?? '';
  type = srcObj?.type ?? '';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions