Check drvinfo.has_value before dereferencing it

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • Fully Compatible
    • Programmability 2025-12-08
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I found this issue experimenting with the -ftrivial-auto-var-init=pattern compile flag.

      `get_info()` returns an optional and the value can indeed be `none`. We dereference it to get the value of `n_stats` without checking for the `none` case. It seems like we've been getting zero for `drvinfo->n_stats` in these cases, but it is UB. With -ftrivial-auto-var-init=pattern, the UB became visible - we instead get a large value that causes a very large memory allocation to fail inside `_get_strings`, leading to a server crash.

      This change makes us check for `none` and explicitly use 0 in that case, causing us to initialize `_names` to an empty vector inside `_get_strings`, which seems like the correct behavior when we can't get `drvinfo`.

            Assignee:
            Ryan Berryhill
            Reporter:
            Ryan Berryhill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: