X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Ftest_sgr.c;h=66241b391ca919b0b3fdcd1a1e5483cdbfab7830;hp=aa7a649ba778415b1beedadb3dd401b866f102cf;hb=a8e3f06ac309504143cd56ac9ec55889bfdf4914;hpb=603f0cb25b7acc8f04f4b18d2a2fe6f90039829a diff --git a/test/test_sgr.c b/test/test_sgr.c index aa7a649b..66241b39 100644 --- a/test/test_sgr.c +++ b/test/test_sgr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2015,2016 Free Software Foundation, Inc. * + * Copyright (c) 2015-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey * - * $Id: test_sgr.c,v 1.7 2016/06/11 23:15:03 tom Exp $ + * $Id: test_sgr.c,v 1.10 2017/04/09 00:27:42 tom Exp $ * * A simple demo of the sgr/sgr0 terminal capabilities. */ @@ -61,8 +61,9 @@ static long total_values; static char * make_dbitem(char *p, char *q) { - char *result = malloc(strlen(e_opt) + 2 + (size_t) (p - q)); - sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q); + size_t need = strlen(e_opt) + 2 + (size_t) (p - q); + char *result = malloc(need); + _nc_SPRINTF(result, _nc_SLIMIT(need) "%s=%.*s", e_opt, (int) (p - q), q); return result; } @@ -117,7 +118,7 @@ next_dbitem(void) return result; } -#ifdef NO_LEAKS +#if NO_LEAKS static void free_dblist(void) { @@ -285,6 +286,9 @@ brute_force(const char *name) } } } + for (count = 0; count < MAXSGR; ++count) { + free(values[count]); + } } del_curterm(cur_term); } @@ -348,7 +352,7 @@ main(int argc, char *argv[]) printf("%ld distinct values\n", total_values); -#ifdef NO_LEAKS +#if NO_LEAKS free_dblist(); #endif