Skip to content

fix: potential TypeError in checkCertificate when stderr is undefined #407

@SangHakLee

Description

@SangHakLee

Problem

When validating an invalid certificate using checkCertificate, a runtime error can occur:

This happens because the implementation tries to call .toString() on stderr, which can be undefined in some cases.

Root Cause

In the current implementation, the code attempts to inspect stderr before handling the error object.
If stderr is undefined, this leads to a TypeError when calling .toString().

Image

Fix

This PR changes the order of error handling to check the error object before accessing stderr.
This ensures that if an error is thrown, it is handled properly and avoids accessing potentially undefined variables.

Question

Is it acceptable to change the order of error handling in this way?
It seems to be a safe and necessary adjustment to prevent unexpected runtime errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions