Skip to content

Conversation

@magnesj
Copy link
Owner

@magnesj magnesj commented Dec 6, 2025

PR Type

Bug fix


Description

  • Guard null pointer dereferences across multiple command features

  • Replace unsafe firstAncestorOrThisOfTypeAsserted() calls with null checks

  • Add null checks for viewer, viewerCommands, and ownerCase pointers

  • Consolidate repeated pointer lookups into single variables


Diagram Walkthrough

flowchart LR
  A["Unsafe pointer dereferences"] -->|Add null checks| B["Safe pointer access"]
  C["Repeated pointer lookups"] -->|Consolidate to variables| D["Single lookup with guard"]
  E["Asserted type casts"] -->|Replace with safe casts| F["Guarded type access"]
Loading

File Walkthrough

Relevant files
Bug fix
21 files
RicApplyUserDefinedCameraFeature.cpp
Guard activeReservoirView null pointer                                     
+5/-1     
RicCreateTextAnnotationIn3dViewFeature.cpp
Guard viewer and ownerCase pointer access                               
+14/-3   
RicNewCellIndexFilterFeature.cpp
Replace asserted cast with null check                                       
+4/-1     
RicNewPolygonFilterFeature.cpp
Replace asserted cast with null check                                       
+4/-1     
RicNewRangeFilterSliceFeature.cpp
Guard view3d pointer before access                                             
+2/-1     
RicNewUserDefinedFilterFeature.cpp
Replace asserted cast with null check                                       
+4/-1     
RicNewUserDefinedIndexFilterFeature.cpp
Replace asserted cast with null check                                       
+4/-1     
RicNewAzimuthDipIntersectionFeature.cpp
Replace asserted cast with null check                                       
+4/-1     
RicAddStoredFlowCharacteristicsPlotFeature.cpp
Guard sourceObject null pointer                                                   
+1/-0     
RicAddStoredWellAllocationPlotFeature.cpp
Guard sourceObject null pointer                                                   
+1/-0     
RicPlaceThermalFractureUsingTemplateDataFeature.cpp
Guard fracture pointer before access                                         
+1/-1     
RicNewFaultReactModelingFeature.cpp
Guard ownerCase pointer access                                                     
+2/-1     
RicCreateGridCrossPlotDataSetFeature.cpp
Guard crossPlot null pointer                                                         
+1/-0     
RicSwapGridCrossPlotDataSetAxesFeature.cpp
Consolidate pointer lookups with null checks                         
+3/-6     
RicIntersectionBoxAtPosFeature.cpp
Guard viewer and viewerCommands pointers                                 
+7/-1     
RicIntersectionFeatureImpl.cpp
Guard viewer and viewerCommands pointers                                 
+7/-1     
RicCopyGridStatisticsToClipboardFeature.cpp
Guard viewer pointer before access                                             
+4/-1     
RicTogglePerspectiveViewFeature.cpp
Guard activeReservoirView pointer access                                 
+17/-10 
RicCreateWellTargetsPickEventHandler.cpp
Guard ownerCase pointer with fallback                                       
+2/-1     
RicWellPathPickEventHandler.cpp
Consolidate measurement pointer lookup                                     
+1/-2     
RimReloadCaseTools.cpp
Guard summaryCase pointer before use                                         
+5/-3     

@qodo-code-review
Copy link

qodo-code-review bot commented Dec 6, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing audit log: The PR adds state-changing UI actions (toggling perspective) without adding any logging of
the action, user, or outcome, which may be considered a critical view change in this
context.

Referred Code
void RicTogglePerspectiveViewFeature::onActionTriggered( bool isChecked )
{
    if ( auto activeReservoirView = RiaApplication::instance()->activeReservoirView() )
    {
        if ( RiaApplication::instance()->activeGridView() && activeReservoirView->viewer() )
        {
            bool isPerspective = activeReservoirView->isPerspectiveView();
            activeReservoirView->isPerspectiveView = !isPerspective;
            activeReservoirView->isPerspectiveView.uiCapability()->updateConnectedEditors();

            activeReservoirView->viewer()->enableParallelProjection( isPerspective );
            activeReservoirView->viewer()->navigationPolicyUpdate();

            action(); // Retrieve the action to update the looks
        }
    }
}

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

qodo-code-review bot commented Dec 6, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add null check for sourceCase

Add a null check for the sourceCase variable before it is used in the
addNewCellRangeFilter function call to prevent a potential crash.

ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp [58-74]

 if ( !filterCollection )
 {
     RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
     if ( activeView )
     {
         filterCollection = activeView->cellFilterCollection();
         sourceCase       = activeView->ownerCase();
     }
 }
 
-if ( filterCollection )
+if ( filterCollection && sourceCase )
 {
     RimCellRangeFilter* lastCreatedOrUpdated = filterCollection->addNewCellRangeFilter( sourceCase, m_sliceDirection );
     if ( lastCreatedOrUpdated )
     {
         Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
     }
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that sourceCase could be a nullptr when passed to addNewCellRangeFilter, which could cause a crash. Adding the null check improves the robustness of the code.

Medium
  • Update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants