/****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. *
+ * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <curses.priv.h>
-MODULE_ID("$Id: trace_buf.c,v 1.18 2011/10/22 15:46:06 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.22 2023/06/24 13:37:25 tom Exp $")
#ifdef TRACE
NCURSES_EXPORT(char *)
_nc_trace_bufcat(int bufnum, const char *value)
{
- char *buffer = _nc_trace_alloc(bufnum, (size_t) 0);
+ char *buffer;
+
+ if (value == NULL)
+ value = "";
+ buffer = _nc_trace_alloc(bufnum, (size_t) 0);
if (buffer != 0) {
size_t have = strlen(buffer);
+ size_t need = strlen(value) + have;
- buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
+ buffer = _nc_trace_alloc(bufnum, 1 + need);
if (buffer != 0)
- (void) strcpy(buffer + have, value);
+ _nc_STRCPY(buffer + have, value, need);
}
return buffer;