Repository: trafodion Updated Branches: refs/heads/master 53f89e6dc -> fa6ae7121
[TRAFODION-3006] unix_timestamp runtime core dump issue Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/bde4454d Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/bde4454d Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/bde4454d Branch: refs/heads/master Commit: bde4454db07386817a754666a17ce819b9b456f2 Parents: 5339170 Author: Liu Ming <[email protected]> Authored: Wed Mar 21 19:52:55 2018 +0000 Committer: Liu Ming <[email protected]> Committed: Wed Mar 21 19:52:55 2018 +0000 ---------------------------------------------------------------------- core/sql/exp/exp_function.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/bde4454d/core/sql/exp/exp_function.cpp ---------------------------------------------------------------------- diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp index 8d9426f..67ca194 100644 --- a/core/sql/exp/exp_function.cpp +++ b/core/sql/exp/exp_function.cpp @@ -2591,16 +2591,22 @@ ex_expr::exp_return_type ex_function_unixtime::eval(char *op_data[], //if there is input value if( getNumOperands() == 2) { - struct tm* ptr; - char* r = strptime(opData, "%Y-%m-%d %H:%M:%S", ptr); + struct tm ptr; + if (opData == NULL ) + { + ExRaiseSqlError(heap, diagsArea, EXE_BAD_ARG_TO_MATH_FUNC); + *(*diagsArea) << DgString0("UNIX_TIMESTAMP"); + return ex_expr::EXPR_ERROR; + } + char* r = strptime(opData, "%Y-%m-%d %H:%M:%S", &ptr); if( (r == NULL) || (*r != '\0') ) { - ExRaiseSqlError(heap, diagsArea, EXE_BAD_ARG_TO_MATH_FUNC); - *(*diagsArea) << DgString0("UNIX_TIMESTAMP"); - return ex_expr::EXPR_ERROR; + ExRaiseSqlError(heap, diagsArea, EXE_BAD_ARG_TO_MATH_FUNC); + *(*diagsArea) << DgString0("UNIX_TIMESTAMP"); + return ex_expr::EXPR_ERROR; } else - *(Int64 *)op_data[0] = mktime(ptr); + *(Int64 *)op_data[0] = mktime(&ptr); } else
