diff options
| author | Sergey Vinokurov <serg.foo@gmail.com> | 2012-09-20 21:58:13 +0300 |
|---|---|---|
| committer | Sergey Vinokurov <serg.foo@gmail.com> | 2012-09-20 22:12:05 +0300 |
| commit | 3d409b08893873b917ccb8c34398bc41a4e84d7c (patch) | |
| tree | 2c6e48ec71fda6829d34e58d83e8fa60b1ad5f73 | |
| parent | ca38792df17fc5c8d2bb6757c512101610420f1e (diff) | |
| download | tinycc-3d409b08893873b917ccb8c34398bc41a4e84d7c.tar.gz tinycc-3d409b08893873b917ccb8c34398bc41a4e84d7c.tar.bz2 | |
fix #include_next infinite loop bug, see http://savannah.nongnu.org/bugs/?31357
| -rw-r--r-- | libtcc.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -34,6 +34,10 @@ ST_DATA struct TCCState *tcc_state; /********************************************************/ +#ifndef _WIN32 +#include <limits.h> +#endif + #ifdef ONE_SOURCE #include "tccpp.c" #include "tccgen.c" @@ -318,7 +322,30 @@ static void tcc_split_path(TCCState *s, void ***p_ary, int *p_nb_ary, const char } } cstr_ccat(&str, '\0'); +#ifndef _WIN32 + { + int i, do_include; + char tmp[PATH_MAX]; + + if (realpath(str.data, tmp)) { + str.size = 0; + cstr_cat(&str, tmp); + cstr_ccat(&str, '\0'); + } + + do_include = 1; + for (i = 0; i < *p_nb_ary && do_include; i++) { + do_include = do_include && + strcmp((char*)str.data, (char*)(*p_ary)[i]); + } + + if (do_include) { + dynarray_add(p_ary, p_nb_ary, str.data); + } + } +#else dynarray_add(p_ary, p_nb_ary, str.data); +#endif in = p+1; } while (*p); } |
