← Commit list

c4603fb09

Denys Vlasenko
Denys Vlasenko
2015-05-25
SUCCESS Duration: 137s

Subject

dc: fix "dc p" prinitng bogus data

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/dc.c+8 -2
@@ -56,6 +56,12 @@ enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(
} while (0)
+static void check_under(void)
+{
+ if (pointer == 0)
+ bb_error_msg_and_die("stack underflow");
+}
+
static void push(double a)
{
if (pointer >= STACK_SIZE)
@@ -65,8 +71,7 @@ static void push(double a)
static double pop(void)
{
- if (pointer == 0)
- bb_error_msg_and_die("stack underflow");
+ check_under();
return stack[--pointer];
}
@@ -187,6 +192,7 @@ static void print_stack_no_pop(void)
static void print_no_pop(void)
{
+ check_under();
print_base(stack[pointer-1]);
}