Skip to content

Commit 5dda340

Browse files
committed
add _n
1 parent 2b4bb67 commit 5dda340

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

include/sentry.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,7 @@ SENTRY_EXPERIMENTAL_API void sentry_options_set_handler_strategy(
17921792
* See the NOTE on attachments above for restrictions of this API.
17931793
*/
17941794
SENTRY_API void sentry_add_attachment(const char *path);
1795+
SENTRY_API void sentry_add_attachment_n(const char *path, size_t path_len);
17951796

17961797
/**
17971798
* Removes a previously added attachment.
@@ -1803,17 +1804,21 @@ SENTRY_API void sentry_add_attachment(const char *path);
18031804
* See the NOTE on attachments above for restrictions of this API.
18041805
*/
18051806
SENTRY_API void sentry_remove_attachment(const char *path);
1807+
SENTRY_API void sentry_remove_attachment_n(const char *path, size_t path_len);
18061808

18071809
#ifdef SENTRY_PLATFORM_WINDOWS
18081810
/**
18091811
* Wide char version of `sentry_add_attachment`.
18101812
*/
18111813
SENTRY_API void sentry_add_attachmentw(const wchar_t *path);
1814+
SENTRY_API void sentry_add_attachmentw_n(const wchar_t *path, size_t path_len);
18121815

18131816
/**
18141817
* Wide char version of `sentry_remove_attachment`.
18151818
*/
18161819
SENTRY_API void sentry_remove_attachmentw(const wchar_t *path);
1820+
SENTRY_API void sentry_remove_attachmentw_n(
1821+
const wchar_t *path, size_t path_len);
18171822
#endif
18181823

18191824
/* -- Session APIs -- */

src/sentry_core.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,13 @@ sentry_capture_minidump_n(const char *path, size_t path_len)
14181418
void
14191419
sentry_add_attachment(const char *path)
14201420
{
1421-
sentry_path_t *attachment = sentry__path_from_str(path);
1421+
sentry_add_attachment_n(path, sentry__guarded_strlen(path));
1422+
}
1423+
1424+
void
1425+
sentry_add_attachment_n(const char *path, size_t path_len)
1426+
{
1427+
sentry_path_t *attachment = sentry__path_from_str_n(path, path_len);
14221428
SENTRY_WITH_OPTIONS (options) {
14231429
if (options->backend && options->backend->add_attachment_func) {
14241430
options->backend->add_attachment_func(options->backend, attachment);
@@ -1433,7 +1439,13 @@ sentry_add_attachment(const char *path)
14331439
void
14341440
sentry_remove_attachment(const char *path)
14351441
{
1436-
sentry_path_t *attachment = sentry__path_from_str(path);
1442+
sentry_remove_attachment_n(path, sentry__guarded_strlen(path));
1443+
}
1444+
1445+
void
1446+
sentry_remove_attachment_n(const char *path, size_t path_len)
1447+
{
1448+
sentry_path_t *attachment = sentry__path_from_str_n(path, path_len);
14371449
SENTRY_WITH_OPTIONS (options) {
14381450
if (options->backend && options->backend->remove_attachment_func) {
14391451
options->backend->remove_attachment_func(
@@ -1449,7 +1461,14 @@ sentry_remove_attachment(const char *path)
14491461
void
14501462
sentry_add_attachmentw(const wchar_t *path)
14511463
{
1452-
sentry_path_t *attachment = sentry__path_from_wstr(path);
1464+
size_t path_len = path ? wcslen(path) : 0;
1465+
sentry_add_attachmentw_n(path, path_len);
1466+
}
1467+
1468+
void
1469+
sentry_add_attachmentw_n(const wchar_t *path, size_t path_len)
1470+
{
1471+
sentry_path_t *attachment = sentry__path_from_wstr_n(path, path_len);
14531472
SENTRY_WITH_OPTIONS (options) {
14541473
if (options->backend && options->backend->add_attachment_func) {
14551474
options->backend->add_attachment_func(options->backend, attachment);
@@ -1464,7 +1483,14 @@ sentry_add_attachmentw(const wchar_t *path)
14641483
void
14651484
sentry_remove_attachmentw(const wchar_t *path)
14661485
{
1467-
sentry_path_t *attachment = sentry__path_from_wstr(path);
1486+
size_t path_len = path ? wcslen(path) : 0;
1487+
sentry_remove_attachmentw_n(path, path_len);
1488+
}
1489+
1490+
void
1491+
sentry_remove_attachmentw_n(const wchar_t *path, size_t path_len)
1492+
{
1493+
sentry_path_t *attachment = sentry__path_from_wstr_n(path, path_len);
14681494
SENTRY_WITH_OPTIONS (options) {
14691495
if (options->backend && options->backend->remove_attachment_func) {
14701496
options->backend->remove_attachment_func(

0 commit comments

Comments
 (0)