Skip to content

Commit

Permalink
Fix bug in printing unsupported formats
Browse files Browse the repository at this point in the history
We should be passing the pointer, not the pointer's value

Fixes #1151
  • Loading branch information
jimhester committed Nov 17, 2020
1 parent a3fc750 commit 97186a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# readr (development version)

* Invalid date formats no longer can potentially crash R (#1151)

# readr 1.4.0

## Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion src/DateTimeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class DateTimeParser {
break;

default:
cpp11::stop("Unsupported format %%%s", *formatItr);
cpp11::stop("Unsupported format %%%s", formatItr);
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-parsing-datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,7 @@ test_that("must have either two - or none", {
expect_equal(guess_parser("200010-10"), "character")
expect_equal(guess_parser("20001010"), "double")
})

test_that("Invalid formats error", {
expect_error(parse_date("2020-11-17", "%%Y-%m-%d"), "Unsupported format %%Y-%m-%d")
})

0 comments on commit 97186a8

Please sign in to comment.