From 2577b55681a97f3eec3fb0e3b5a4fb7f2cb18b8a Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 30 Aug 2018 00:42:04 +0200 Subject: sync with upstream --- .../include/kodi/libXBMC_addon.h | 33 +++++++++------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h index 271df98..43e3022 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h @@ -1,24 +1,13 @@ -#pragma once /* - * Copyright (C) 2005-2013 Team XBMC - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. */ +#pragma once + #include #include #include @@ -195,7 +184,7 @@ namespace ADDON m_Callbacks = (KodiAPI::AddOn::CB_AddOnLib*)m_Handle->AddOnLib_RegisterMe(m_Handle->addonData); if (!m_Callbacks) fprintf(stderr, "libXBMC_addon-ERROR: AddOnLib_RegisterMe can't get callback table from Kodi !!!\n"); - + return m_Callbacks != nullptr; } @@ -203,14 +192,18 @@ namespace ADDON * @brief Add a message to XBMC's log. * @param loglevel The log level of the message. * @param format The format of the message to pass to XBMC. + * @note This method uses limited buffer (16k) for the formatted output. + * So data, which will not fit into it, will be silently discarded. */ void Log(const addon_log_t loglevel, const char *format, ... ) { char buffer[16384]; + static constexpr size_t len = sizeof (buffer) - 1; va_list args; va_start (args, format); - vsprintf (buffer, format, args); + vsnprintf (buffer, len, format, args); va_end (args); + buffer[len] = '\0'; // to be sure it's null-terminated m_Callbacks->Log(m_Handle->addonData, loglevel, buffer); } @@ -297,7 +290,7 @@ namespace ADDON { m_Callbacks->FreeString(m_Handle->addonData, str); } - + /*! * @brief Free the memory used by arr including its elements * @param arr The string array to free -- cgit v1.2.3