From e656f75767dbeb5f71204b48bd820dea222377d8 Mon Sep 17 00:00:00 2001 From: Aleksei Romanov Date: Sun, 3 Nov 2024 00:59:49 +0300 Subject: [PATCH] Fix possible nullptr dereference --- elfio/elfio.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elfio/elfio.hpp b/elfio/elfio.hpp index 49cfd3c..2db86d7 100644 --- a/elfio/elfio.hpp +++ b/elfio/elfio.hpp @@ -138,8 +138,12 @@ class elfio bool load( const std::string& file_name, bool is_lazy = false ) { pstream = std::make_unique(); + if ( !pstream ) { + return false; + } + pstream->open( file_name.c_str(), std::ios::in | std::ios::binary ); - if ( pstream == nullptr || !*pstream ) { + if ( !*pstream ) { return false; }