mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-13 15:59:50 -04:00
Merge branch 'chme-string_printf'
This commit is contained in:
commit
b20f3725ad
24
src/misc.c
24
src/misc.c
@ -32,6 +32,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#ifndef CLOCK_REALTIME
|
#ifndef CLOCK_REALTIME
|
||||||
@ -286,6 +287,27 @@ safe_strdup(const char *str)
|
|||||||
return strdup(str);
|
return strdup(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapper function for vasprintf by Intel Corporation
|
||||||
|
* Published under the L-GPL 2.1 licence as part of clr-boot-manager
|
||||||
|
*
|
||||||
|
* https://github.com/clearlinux/clr-boot-manager
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
safe_asprintf(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char *ret = NULL;
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
if (vasprintf(&ret, fmt, va) < 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_FATAL, L_MISC, "Out of memory for safe_asprintf\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
va_end(va);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Key/value functions */
|
/* Key/value functions */
|
||||||
struct keyval *
|
struct keyval *
|
||||||
@ -1132,3 +1154,5 @@ log_fatal_null(int domain, const char *func, int line)
|
|||||||
DPRINTF(E_FATAL, domain, "%s returned NULL at line %d\n", func, line);
|
DPRINTF(E_FATAL, domain, "%s returned NULL at line %d\n", func, line);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +50,10 @@ safe_hextou64(const char *str, uint64_t *val);
|
|||||||
char *
|
char *
|
||||||
safe_strdup(const char *str);
|
safe_strdup(const char *str);
|
||||||
|
|
||||||
|
char *
|
||||||
|
safe_asprintf(const char *fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
/* Key/value functions */
|
/* Key/value functions */
|
||||||
struct keyval *
|
struct keyval *
|
||||||
keyval_alloc(void);
|
keyval_alloc(void);
|
||||||
|
@ -244,9 +244,9 @@ spotifywebapi_request_next(struct spotify_request *request, const char *uri, boo
|
|||||||
if (append_market && spotify_user_country)
|
if (append_market && spotify_user_country)
|
||||||
{
|
{
|
||||||
if (strchr(uri, '?'))
|
if (strchr(uri, '?'))
|
||||||
asprintf(&next_uri, "%s&market=%s", uri, spotify_user_country);
|
next_uri = safe_asprintf("%s&market=%s", uri, spotify_user_country);
|
||||||
else
|
else
|
||||||
asprintf(&next_uri, "%s?market=%s", uri, spotify_user_country);
|
next_uri = safe_asprintf("%s?market=%s", uri, spotify_user_country);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
next_uri = strdup(uri);
|
next_uri = strdup(uri);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user