-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Location: Queue_using_stack.cpp Issue: Lack of underflow protection in pop() and peek() functions.
Analysis: The code directly calls s1.top() (or s2.top()) without verifying if the stacks contain any elements. In C++, calling .top() on an empty std::stack is undefined behavior and leads to a Segmentation Fault (program crash). A robust implementation must check if (s1.empty()) before attempting to access the top element.
Impact: Any user calling dequeue on an empty queue will cause the entire application to crash.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels