mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-02 08:15:56 +01:00
Fix null check in fixReferences to prevent crash on null property values
The fixReferences function in jsonSchema_v2.ts would crash with "Cannot read properties of null (reading '$ref')" when a task definition from an extension contained null property values. typeof null === 'object' in JavaScript, so the guard on line 31 would pass for null values, causing a recursive call into null. The array element path (line 21) already had a null check but the object property path was missing it. Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/97290369-e210-4404-b2b7-7c8ca4a2f84b Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
eaf6f5ee14
commit
ebbc16c20b
@@ -28,7 +28,7 @@ function fixReferences(literal: Record<string, unknown> | unknown[]) {
|
||||
}
|
||||
Object.getOwnPropertyNames(literal).forEach(property => {
|
||||
const value = literal[property];
|
||||
if (Array.isArray(value) || typeof value === 'object') {
|
||||
if (Array.isArray(value) || (typeof value === 'object' && value !== null)) {
|
||||
fixReferences(value as Record<string, unknown>);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user