|
|
d4160e0 |
From d6507e52adcf851d8888b93f9905f0fad1052af2 Mon Sep 17 00:00:00 2001
|
|
|
d4160e0 |
From: Robin Lee <cheeselee@fedoraproject.org>
|
|
|
d4160e0 |
Date: Sun, 16 Feb 2020 02:37:42 +0800
|
|
|
d4160e0 |
Subject: [PATCH] Fix crashing of tests when '-Wp,-D_GLIBCXX_ASSERTIONS' is
|
|
|
d4160e0 |
given
|
|
|
d4160e0 |
|
|
|
d4160e0 |
If 'vec' is a vector, calling 'vec[0]' will crash the program if
|
|
|
d4160e0 |
'vec' is empty and '-Wp,-D_GLIBCXX_ASSERTIONS' given in CXXFLAGS.
|
|
|
d4160e0 |
|
|
|
d4160e0 |
Fixes https://github.com/gearman/gearmand/issues/272
|
|
|
d4160e0 |
---
|
|
|
d4160e0 |
libtest/cmdline.h | 4 ++--
|
|
|
d4160e0 |
tests/hostile.cc | 2 +-
|
|
|
d4160e0 |
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
d4160e0 |
|
|
|
d4160e0 |
diff --git a/libtest/cmdline.h b/libtest/cmdline.h
|
|
|
d4160e0 |
index 692363f6..3503bada 100644
|
|
|
d4160e0 |
--- a/libtest/cmdline.h
|
|
|
d4160e0 |
+++ b/libtest/cmdline.h
|
|
|
d4160e0 |
@@ -153,7 +153,7 @@ class Application {
|
|
|
d4160e0 |
|
|
|
d4160e0 |
const char* stdout_c_str() const
|
|
|
d4160e0 |
{
|
|
|
d4160e0 |
- return &_stdout_buffer[0];
|
|
|
d4160e0 |
+ return _stdout_buffer.size() ? &_stdout_buffer[0] : NULL;
|
|
|
d4160e0 |
}
|
|
|
d4160e0 |
|
|
|
d4160e0 |
libtest::vchar_t stderr_result() const
|
|
|
d4160e0 |
@@ -163,7 +163,7 @@ class Application {
|
|
|
d4160e0 |
|
|
|
d4160e0 |
const char* stderr_c_str() const
|
|
|
d4160e0 |
{
|
|
|
d4160e0 |
- return &_stderr_buffer[0];
|
|
|
d4160e0 |
+ return _stderr_buffer.size() ? &_stderr_buffer[0] : NULL;
|
|
|
d4160e0 |
}
|
|
|
d4160e0 |
|
|
|
d4160e0 |
size_t stderr_result_length() const
|
|
|
d4160e0 |
diff --git a/tests/hostile.cc b/tests/hostile.cc
|
|
|
d4160e0 |
index c4c0487d..c7686206 100644
|
|
|
d4160e0 |
--- a/tests/hostile.cc
|
|
|
d4160e0 |
+++ b/tests/hostile.cc
|
|
|
d4160e0 |
@@ -136,7 +136,7 @@ extern "C" {
|
|
|
d4160e0 |
gearman_return_t rc;
|
|
|
d4160e0 |
void *value= gearman_client_do(&client, WORKER_FUNCTION_NAME,
|
|
|
d4160e0 |
NULL,
|
|
|
d4160e0 |
- &payload[0],
|
|
|
d4160e0 |
+ payload.size() ? &payload[0] : NULL,
|
|
|
d4160e0 |
payload.size() ? random() % payload.size() : 0,
|
|
|
d4160e0 |
NULL, &rc);
|
|
|
d4160e0 |
|