Building with GCC 11 fails with: ``` [task 2021-05-19T00:00:35.298Z] 00:00:35 INFO - In file included from Unified_cpp_accessible_xpcom0.cpp:65: [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp: In member function 'virtual nsresult mozilla::a11y::xpcAccessibleHyperText::GetTextAttributes(bool, int32_t, int32_t*, int32_t*, nsIPersistentProperties**)': [task 2021-05-19T00:00:35.299Z] 00:00:35 ERROR - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp:194:31: error: 'this' pointer is null [-Werror=nonnull] [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - 194 | props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused); [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp: In member function 'virtual nsresult mozilla::a11y::xpcAccessibleHyperText::GetDefaultTextAttributes(nsIPersistentProperties**)': [task 2021-05-19T00:00:35.299Z] 00:00:35 ERROR - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp:223:31: error: 'this' pointer is null [-Werror=nonnull] [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - 223 | props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused); [task 2021-05-19T00:00:35.300Z] 00:00:35 INFO - | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [task 2021-05-19T00:00:35.300Z] 00:00:35 INFO - cc1plus: all warnings being treated as errors ``` The code in both cases, looks like: ``` nsCOMPtr<nsIPersistentProperties> props; if (...) { ... } else { ... props->SetStringProperty(...); } ``` It blows my mind that this obvious null deref hasn't caused crashes on Mac and Linux in the 5 years that this code has been around.
Bug 1711811 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Building with GCC 11 fails with: ``` [task 2021-05-19T00:00:35.298Z] 00:00:35 INFO - In file included from Unified_cpp_accessible_xpcom0.cpp:65: [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp: In member function 'virtual nsresult mozilla::a11y::xpcAccessibleHyperText::GetTextAttributes(bool, int32_t, int32_t*, int32_t*, nsIPersistentProperties**)': [task 2021-05-19T00:00:35.299Z] 00:00:35 ERROR - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp:194:31: error: 'this' pointer is null [-Werror=nonnull] [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - 194 | props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused); [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp: In member function 'virtual nsresult mozilla::a11y::xpcAccessibleHyperText::GetDefaultTextAttributes(nsIPersistentProperties**)': [task 2021-05-19T00:00:35.299Z] 00:00:35 ERROR - /builds/worker/checkouts/gecko/accessible/xpcom/xpcAccessibleHyperText.cpp:223:31: error: 'this' pointer is null [-Werror=nonnull] [task 2021-05-19T00:00:35.299Z] 00:00:35 INFO - 223 | props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused); [task 2021-05-19T00:00:35.300Z] 00:00:35 INFO - | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [task 2021-05-19T00:00:35.300Z] 00:00:35 INFO - cc1plus: all warnings being treated as errors ``` The code in both cases, looks like: ``` nsCOMPtr<nsIPersistentProperties> props; if (...) { props = ... } else { ... props->SetStringProperty(...); } ``` It blows my mind that this obvious null deref hasn't caused crashes on Mac and Linux in the 5 years that this code has been around.