From a00b3766fa4c498a65f5742e161a382717db3041 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 21 Nov 2013 18:29:25 +0000 Subject: value2timespec: use StringValueCStr for correctness rb_inspect is unlikely to put a \0 byte in the middle of a string, but use StringValueCStr anyways just in case to catch potential bugs. --- ext/sleepy_penguin/value2timespec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/sleepy_penguin/value2timespec.h b/ext/sleepy_penguin/value2timespec.h index 8f6830b..b8f6167 100644 --- a/ext/sleepy_penguin/value2timespec.h +++ b/ext/sleepy_penguin/value2timespec.h @@ -42,8 +42,8 @@ static struct timespec *value2timespec(struct timespec *ts, VALUE num) }} { VALUE tmp = rb_inspect(num); - rb_raise(rb_eTypeError, "can't convert %s into timespec", - StringValuePtr(tmp)); + const char *str = StringValueCStr(tmp); + rb_raise(rb_eTypeError, "can't convert %s into timespec", str); } rb_bug("rb_raise() failed, timespec failed"); return NULL; -- cgit v1.2.3-24-ge0c7