[tarantool-patches] Re: [PATCH v2 2/2] Added strdup fail checks in say

  • From: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
  • To: Olga Arkhangelskaia <arkholga@xxxxxxxxxxxxx>
  • Date: Thu, 19 Jul 2018 15:26:16 +0300

On Thu, Jul 19, 2018 at 01:54:49PM +0300, Olga Arkhangelskaia wrote:

Strdup may silently fail without any message from tarantool.
Patch adds this checks.
---
Branch: https://github.com/tarantool/tarantool/tree/OKriw/refactor-log-cfg

v1:
https://www.freelists.org/post/tarantool-patches/PATCH-22-Added-strdup-fail-checks-in-say

Changes in v2:
- no double check now

 src/say.c | 5 +++++
 1 file changed, 5 insertions(+)

This one looks good to me.


diff --git a/src/say.c b/src/say.c
index 92e0e6d9f..99344b685 100644
--- a/src/say.c
+++ b/src/say.c
@@ -502,6 +502,11 @@ log_syslog_init(struct log *log, const char *init_str)
              log->syslog_ident = strdup("tarantool");
      else
              log->syslog_ident = strdup(opts.identity);
+     if (log->syslog_ident == NULL) {
+             diag_set(OutOfMemory, strlen(opts.identity), "malloc",
+                      "log->syslog_ident");
+             return -1;
+     }
 
      if (opts.facility == syslog_facility_MAX)
              log->syslog_facility = SYSLOG_LOCAL7;

Other related posts: