Skip to content

Commit

Permalink
Merge pull request #672 from argilo/polarpuppet-length-checks
Browse files Browse the repository at this point in the history
Add length checks to puppets
  • Loading branch information
jdemel authored Nov 4, 2023
2 parents 4292073 + a279d23 commit fa2f5a2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
12 changes: 12 additions & 0 deletions kernels/volk/volk_32f_8u_polarbutterflypuppet_32f.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ static inline void volk_32f_8u_polarbutterflypuppet_32f_generic(float* llrs,
unsigned char* u,
const int elements)
{
if (elements < 2) {
return;
}

unsigned int frame_size = maximum_frame_size(elements);
unsigned int frame_exp = log2_of_power_of_2(frame_size);

Expand All @@ -104,6 +108,10 @@ static inline void volk_32f_8u_polarbutterflypuppet_32f_u_avx(float* llrs,
unsigned char* u,
const int elements)
{
if (elements < 2) {
return;
}

unsigned int frame_size = maximum_frame_size(elements);
unsigned int frame_exp = log2_of_power_of_2(frame_size);

Expand All @@ -127,6 +135,10 @@ static inline void volk_32f_8u_polarbutterflypuppet_32f_u_avx2(float* llrs,
unsigned char* u,
const int elements)
{
if (elements < 2) {
return;
}

unsigned int frame_size = maximum_frame_size(elements);
unsigned int frame_exp = log2_of_power_of_2(frame_size);

Expand Down
20 changes: 20 additions & 0 deletions kernels/volk/volk_8u_x3_encodepolarpuppet_8u.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ volk_8u_x3_encodepolarpuppet_8u_generic(unsigned char* frame,
const unsigned char* info_bits,
unsigned int frame_size)
{
if (frame_size < 1) {
return;
}

frame_size = next_lower_power_of_two(frame_size);
unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
volk_get_alignment());
Expand All @@ -67,6 +71,10 @@ volk_8u_x3_encodepolarpuppet_8u_u_ssse3(unsigned char* frame,
const unsigned char* info_bits,
unsigned int frame_size)
{
if (frame_size < 1) {
return;
}

frame_size = next_lower_power_of_two(frame_size);
unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
volk_get_alignment());
Expand All @@ -85,6 +93,10 @@ volk_8u_x3_encodepolarpuppet_8u_u_avx2(unsigned char* frame,
const unsigned char* info_bits,
unsigned int frame_size)
{
if (frame_size < 1) {
return;
}

frame_size = next_lower_power_of_two(frame_size);
unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
volk_get_alignment());
Expand All @@ -108,6 +120,10 @@ volk_8u_x3_encodepolarpuppet_8u_a_ssse3(unsigned char* frame,
const unsigned char* info_bits,
unsigned int frame_size)
{
if (frame_size < 1) {
return;
}

frame_size = next_lower_power_of_two(frame_size);
unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
volk_get_alignment());
Expand All @@ -126,6 +142,10 @@ volk_8u_x3_encodepolarpuppet_8u_a_avx2(unsigned char* frame,
const unsigned char* info_bits,
unsigned int frame_size)
{
if (frame_size < 1) {
return;
}

frame_size = next_lower_power_of_two(frame_size);
unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
volk_get_alignment());
Expand Down
2 changes: 1 addition & 1 deletion lib/volk_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
void* volk_malloc(size_t size, size_t alignment)
{
if ((size == 0) || (alignment == 0)) {
fprintf(stderr, "VOLK: Error allocating memory: either size or alignment is 0");
fprintf(stderr, "VOLK: Error allocating memory: either size or alignment is 0\n");
return NULL;
}
// Tweak size to satisfy ASAN (the GCC address sanitizer).
Expand Down

0 comments on commit fa2f5a2

Please sign in to comment.