From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 7EE6C2485E for ; Wed, 17 Jul 2019 13:18:33 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WW6ZIhazdVmt for ; Wed, 17 Jul 2019 13:18:33 -0400 (EDT) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 2F32C24843 for ; Wed, 17 Jul 2019 13:18:33 -0400 (EDT) Received: by mail-lj1-f196.google.com with SMTP id v18so24388891ljh.6 for ; Wed, 17 Jul 2019 10:18:33 -0700 (PDT) From: Mons Anderson Subject: [tarantool-patches] [PATCH] log: fix segfault on _say without filename Date: Wed, 17 Jul 2019 17:18:21 +0000 Message-Id: <1563383901-12794-1-git-send-email-mons@cpan.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Mons Anderson --- src/say.c | 6 +++--- test/box/misc.result | 13 +++++++++++++ test/box/misc.test.lua | 8 ++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/say.c b/src/say.c index def948d..6b01bc3 100644 --- a/src/say.c +++ b/src/say.c @@ -772,10 +772,10 @@ say_format_plain_tail(char *buf, int len, int level, const char *filename, if (level == S_WARN || level == S_ERROR || level == S_SYSERROR) { /* Primitive basename(filename) */ - for (const char *f = filename; *f; f++) - if (*f == '/' && *(f + 1) != '\0') - filename = f + 1; if (filename) { + for (const char *f = filename; *f; f++) + if (*f == '/' && *(f + 1) != '\0') + filename = f + 1; SNPRINT(total, snprintf, buf, len, " %s:%i", filename, line); } diff --git a/test/box/misc.result b/test/box/misc.result index 699358d..e717493 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -1207,3 +1207,16 @@ box.cfg{too_long_threshold = too_long_threshold} s:drop() --- ... +-- +-- +-- +box.cfg{} +--- +... +local ffi = require'ffi' ffi.C._say(ffi.C.S_WARN, nil, 0, nil, "%s", "test log") +--- +... +test_run:grep_log('default', 'test log') +--- +- test log +... diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua index ee81c7b..b7154ff 100644 --- a/test/box/misc.test.lua +++ b/test/box/misc.test.lua @@ -342,3 +342,11 @@ rows == expected_rows lsn == expected_lsn box.cfg{too_long_threshold = too_long_threshold} s:drop() + +-- +-- Test for segfault +-- + +box.cfg{} +local ffi = require'ffi' ffi.C._say(ffi.C.S_WARN, nil, 0, nil, "%s", "test log") +test_run:grep_log('default', 'test log') -- 1.8.3.1