Skip to content

Commit

Permalink
fix segfault and compilation error on OSX10.9 and FreeBSD 10 with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
erkmos committed May 22, 2014
1 parent 834d79c commit f129037
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crypto/oaes_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ static const char _NR[] = {
#include <stddef.h>
#include <time.h>
#include <sys/timeb.h>
#if !((defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__APPLE__))
#include <malloc.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions cryptonight.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void cryptonight_hash_ctx(void* output, const void* input, size_t len, struct cr
}

void cryptonight_hash(void* output, const void* input, size_t len) {
cryptonight_hash_ctx(output, input, len, alloca(sizeof(struct cryptonight_ctx)));
cryptonight_hash_ctx(output, input, len, malloc(sizeof(struct cryptonight_ctx)));
}

void cryptonight_hash_ctx_aes_ni(void* output, const void* input, size_t len, struct cryptonight_ctx* ctx) {
Expand Down Expand Up @@ -269,7 +269,7 @@ int scanhash_cryptonight(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
const uint32_t Htarg = ptarget[7];
uint32_t hash[HASH_SIZE / 4] __attribute__((aligned(32)));

struct cryptonight_ctx *ctx = alloca(sizeof(struct cryptonight_ctx));
struct cryptonight_ctx *ctx = malloc(sizeof(struct cryptonight_ctx));

if (aes_ni) {
do {
Expand Down

0 comments on commit f129037

Please sign in to comment.