Skip to content

Commit e6ea228

Browse files
committed
apply suggestions from code review
1 parent 6da5184 commit e6ea228

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ sentry_target_sources_cwd(sentry
1515
sentry_json.h
1616
sentry_logger.c
1717
sentry_logger.h
18+
sentry_logs.c
19+
sentry_logs.h
1820
sentry_options.c
1921
sentry_options.h
2022
sentry_os.c
@@ -51,8 +53,6 @@ sentry_target_sources_cwd(sentry
5153
transports/sentry_disk_transport.h
5254
transports/sentry_function_transport.c
5355
unwinder/sentry_unwinder.c
54-
sentry_logs.c
55-
sentry_logs.h
5656
)
5757

5858
# generic platform / path / symbolizer

src/sentry_logs.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ skip_precision(const char *fmt_ptr)
145145
return fmt_ptr;
146146
}
147147

148+
static const char *
149+
skip_length(const char *fmt_ptr)
150+
{
151+
while (*fmt_ptr
152+
&& (*fmt_ptr == 'h' || *fmt_ptr == 'l' || *fmt_ptr == 'L'
153+
|| *fmt_ptr == 'z' || *fmt_ptr == 'j' || *fmt_ptr == 't')) {
154+
fmt_ptr++;
155+
}
156+
return fmt_ptr;
157+
}
158+
148159
static void
149160
populate_message_parameters(
150161
sentry_value_t attributes, const char *message, va_list args)
@@ -172,13 +183,7 @@ populate_message_parameters(
172183
fmt_ptr = skip_flags(fmt_ptr);
173184
fmt_ptr = skip_width(fmt_ptr);
174185
fmt_ptr = skip_precision(fmt_ptr);
175-
176-
// Skip length modifiers
177-
while (*fmt_ptr
178-
&& (*fmt_ptr == 'h' || *fmt_ptr == 'l' || *fmt_ptr == 'L'
179-
|| *fmt_ptr == 'z' || *fmt_ptr == 'j' || *fmt_ptr == 't')) {
180-
fmt_ptr++;
181-
}
186+
fmt_ptr = skip_length(fmt_ptr);
182187

183188
// Get the conversion specifier
184189
char conversion = *fmt_ptr;

src/sentry_value.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ sentry_value_new_int32(int32_t value)
317317
sentry_value_t
318318
sentry_value_new_double(double value)
319319
{
320-
thing_t *thing = sentry_malloc(sizeof(thing_t));
320+
thing_t *thing = SENTRY_MAKE(thing_t);
321321
if (!thing) {
322322
return sentry_value_new_null();
323323
}
@@ -333,7 +333,7 @@ sentry_value_new_double(double value)
333333
sentry_value_t
334334
sentry_value_new_int64(int64_t value)
335335
{
336-
thing_t *thing = sentry_malloc(sizeof(thing_t));
336+
thing_t *thing = SENTRY_MAKE(thing_t);
337337
if (!thing) {
338338
return sentry_value_new_null();
339339
}
@@ -349,7 +349,7 @@ sentry_value_new_int64(int64_t value)
349349
sentry_value_t
350350
sentry_value_new_uint64(uint64_t value)
351351
{
352-
thing_t *thing = sentry_malloc(sizeof(thing_t));
352+
thing_t *thing = SENTRY_MAKE(thing_t);
353353
if (!thing) {
354354
return sentry_value_new_null();
355355
}
@@ -666,6 +666,9 @@ sentry__value_as_uuid(sentry_value_t value)
666666
char *
667667
sentry__value_stringify(sentry_value_t value)
668668
{
669+
// returns empty string if snprintf fails
670+
// (returning -1, so casting this to size_t it becomes > the buffer size)
671+
// or if the value is too large for the buffer
669672
#define STRINGIFY_NUMERIC(fmt, value_fn) \
670673
do { \
671674
char buf[24]; \

tests/unit/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ add_executable(sentry_test_unit
2828
test_fuzzfailures.c
2929
test_info.c
3030
test_logger.c
31-
test_logs.c
31+
test_logs.c
3232
test_modulefinder.c
3333
test_mpack.c
3434
test_options.c

0 commit comments

Comments
 (0)