DRAGMAP icon indicating copy to clipboard operation
DRAGMAP copied to clipboard

Use gnu99 instead of c99, as strdup is not part of C99

Open lgruen opened this issue 2 years ago • 0 comments

With c99 only, strdup is not defined (see https://stackoverflow.com/questions/26284110/strdup-confused-about-warnings-implicit-declaration-makes-pointer-with for context). Consequently, https://github.com/Illumina/DRAGMAP/blob/ef182bda173d1ca9919b93fae99f068802ed20fc/thirdparty/dragen/src/common/hash_generation/gen_hash_table.c#L158 assigns an invalid pointer value to dir, which cannot be read afterwards (e.g. using gcc 9 in the Ubuntu 20.04 Docker image), leading to a segfault. gcc warns about this:

/DRAGMAP-1.2.1/thirdparty/dragen/src/common/hash_generation/gen_hash_table.c: In function 'setDefaultHashParams':
/DRAGMAP-1.2.1/thirdparty/dragen/src/common/hash_generation/gen_hash_table.c:158:24: warning: implicit declaration of function 'strdup'; did you mean 'strcmp'? [-Wimplicit-function-declaration]
  158 |     if (destDir) dir = strdup(destDir);
      |                        ^~~~~~
      |                        strcmp
/DRAGMAP-1.2.1/thirdparty/dragen/src/common/hash_generation/gen_hash_table.c:158:22: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  158 |     if (destDir) dir = strdup(destDir);

lgruen avatar Oct 04 '21 00:10 lgruen