wangzhengquan
2021-01-15 0d6000e8e75e45d83dfc5718bd249a11fcce45a3
src/bus_error.cpp
@@ -41,9 +41,9 @@
char *
bus_strerror(int err)
{
  int s;
  int s, eindex;
  char *buf;
  eindex = err - 10000;
  /* Make first caller allocate key for thread-specific data */
  s = pthread_once(&once, createKey);
@@ -64,13 +64,13 @@
      err_exit(s, "pthread_setspecific");
  }
  if (err < 0 || err >= _bus_nerr || _bus_errlist[err] == NULL)
  if (eindex < 0 || eindex >= _bus_nerr || _bus_errlist[eindex] == NULL)
  {
    snprintf(buf, MAX_ERROR_LEN, "Unknown error %d", err);
    snprintf(buf, MAX_ERROR_LEN, "Unknown error %d", eindex);
  }
  else
  {
    strncpy(buf, _bus_errlist[err], MAX_ERROR_LEN - 1);
    strncpy(buf, _bus_errlist[eindex], MAX_ERROR_LEN - 1);
    buf[MAX_ERROR_LEN - 1] = '\0';          /* Ensure null termination */
  }