diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2000-10-18 17:09:35 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2000-10-18 17:09:35 +0100 |
commit | 81cf47b209c433b6cb1ccffb030789a06ffa5c16 (patch) | |
tree | 85c536f50f4a4636eb737ad764e804903e9b46cd /gcc/c-common.c | |
parent | 27c35f4b2435bc05271dca75ec26a585e6853f4a (diff) | |
download | gcc-81cf47b209c433b6cb1ccffb030789a06ffa5c16.zip gcc-81cf47b209c433b6cb1ccffb030789a06ffa5c16.tar.gz gcc-81cf47b209c433b6cb1ccffb030789a06ffa5c16.tar.bz2 |
c-common.c (check_format_types): Check for writing through a NULL pointer argument.
* c-common.c (check_format_types): Check for writing through a
NULL pointer argument.
testsuite:
* gcc.dg/c90-printf-1.c, gcc.dg/c90-scanf-1.c: Add tests for
writing through null pointers; remove comment about testing
unterminated strings.
From-SVN: r36936
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index e9548dc..09cb949 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3119,6 +3119,15 @@ check_format_types (status, types) if (TREE_CODE (cur_type) == ERROR_MARK) break; + /* Check for writing through a NULL pointer. */ + if (types->writing_in_flag + && i == 0 + && cur_param != 0 + && integer_zerop (cur_param)) + status_warning (status, + "writing through null pointer (arg %d)", + arg_num); + if (cur_param != 0 && TREE_CODE (cur_param) == ADDR_EXPR) cur_param = TREE_OPERAND (cur_param, 0); else |