on master help sign in
Merge pull request #2005 from david-christiansen/ahmadsalim-testing/cstaticanalysis
6ba74daDavid Christiansen
.travis.yml+2
@@ -16,6 +16,7 @@ before_install:
16 - sudo apt-get install hscolour
16 - sudo apt-get install hscolour
17 # test dependency
17 # test dependency
18 - sudo apt-get install -qq expect
18 - sudo apt-get install -qq expect
19+ - sudo apt-get install -qq cppcheck
19 - cabal install alex-3.1.3
20 - cabal install alex-3.1.3
20install:
21install:
21 - cabal install -f FFI --enable-tests --dependencies-only
22 - cabal install -f FFI --enable-tests --dependencies-only
@@ -30,6 +31,7 @@ script:
30 - if [[ "$TESTS" != "doc" ]]; then cabal build; fi
31 - if [[ "$TESTS" != "doc" ]]; then cabal build; fi
31 - if [[ "$TESTS" != "doc" ]]; then cabal copy; fi
32 - if [[ "$TESTS" != "doc" ]]; then cabal copy; fi
32 - if [[ "$TESTS" != "doc" ]]; then cabal register; fi
33 - if [[ "$TESTS" != "doc" ]]; then cabal register; fi
34+ - if [[ "$TESTS" == "test_c" ]]; then cppcheck -j 2 --error-exitcode=1 ./rts/idris_bitstring.c ./rts/idris_bitstring.h ./rts/idris_gc.h ./rts/idris_gc.c ./rts/idris_gmp.h ./rts/idris_gmp.c ./rts/idris_heap.h ./rts/idris_heap.c ./rts/idris_main.c ./rts/idris_net.h ./rts/idris_net.c ./rts/idris_opts.h ./rts/idris_opts.c ./rts/idris_rts.h ./rts/idris_rts.c ./rts/idris_stats.h ./rts/idris_stats.c ./rts/idris_stdfgn.h ./rts/idris_stdfgn.c ./rts/libtest.c ; fi
33 - if [[ "$TESTS" == "test_llvm" ]]; then git clone --depth 1 https://github.com/idris-hackers/idris-llvm.git ; cd idris-llvm ; cabal install ; cd .. ; fi
35 - if [[ "$TESTS" == "test_llvm" ]]; then git clone --depth 1 https://github.com/idris-hackers/idris-llvm.git ; cd idris-llvm ; cabal install ; cd .. ; fi
34 - make -j2 $TESTS
36 - make -j2 $TESTS
35env:
37env:
rts/idris_rts.c+10−2
@@ -621,8 +621,16 @@ VAL idris_readStr(VM* vm, FILE* h) {
621 {
621 {
622 /* Make the buffer bigger and read more of the line */
622 /* Make the buffer bigger and read more of the line */
623 line_buf_size += BUFSIZE;
623 line_buf_size += BUFSIZE;
624+ { /* limit the scope of new_line_buf to where it's needed for errors*/
624− line_buf = (char *) realloc (line_buf, line_buf_size);
625+ char *new_line_buf = realloc (line_buf, line_buf_size);
625−
626+ if (new_line_buf == NULL)
627+ {
628+ fprintf(stderr, "Fatal Error: couldn't allocate a larger line buffer.");
629+ exit(EXIT_FAILURE);
630+ } else {
631+ line_buf = new_line_buf;
632+ }
633+ }
626 /* points to last byte again */
634 /* points to last byte again */
627 line_ptr = line_buf + line_buf_size - 1;
635 line_ptr = line_buf + line_buf_size - 1;
628 /* so we can see if fgets put a 0 there */
636 /* so we can see if fgets put a 0 there */