Skip to content

Commit

Permalink
Fix alloca usage on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
roehling committed Aug 7, 2023
1 parent 7cf032d commit 01f4264
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,10 @@ if(WITH_SQLITE)
SQLITE_OMIT_DEPRECATED
SQLITE_OMIT_PROGRESS_CALLBACK
SQLITE_OMIT_SHARED_CACHE
SQLITE_USE_ALLOCA
)
if(HAVE_ALLOCA_H)
target_compile_definitions(sqlite3 PRIVATE SQLITE_USE_ALLOCA)
endif()
if(WITH_MILTER AND TARGET Threads::Threads)
target_link_libraries(sqlite3 PRIVATE Threads::Threads)
endif()
Expand Down
9 changes: 7 additions & 2 deletions src/srs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

#include <postsrsd_build_config.h>
#include <stdarg.h>
#include <string.h> /* memcpy, strcpy, memset */
#include <strings.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
Expand Down Expand Up @@ -285,7 +283,11 @@ static void srs_hash_create_v(srs_t* srs, int idx, char* buf, int nargs,
{
data = va_arg(ap, char*);
len = strlen(data);
#ifndef HAVE_ALLOCA_H
lcdata = malloc(len + 1);
#else
lcdata = alloca(len + 1);
#endif
for (j = 0; j < len; j++)
{
if (isupper(data[j]))
Expand All @@ -297,6 +299,9 @@ static void srs_hash_create_v(srs_t* srs, int idx, char* buf, int nargs,
HMAC_Update(&ctx, lcdata, len);
#else
srs_hmac_update(&ctx, lcdata, len);
#endif
#ifndef HAVE_ALLOCA_H
free(lcdata);
#endif
}

Expand Down

0 comments on commit 01f4264

Please sign in to comment.