about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-11-21 18:29:25 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-21 18:29:25 +0000
commita00b3766fa4c498a65f5742e161a382717db3041 (patch)
tree089748c197149c8f6ca2907e7f5064e4c02e8f2d
parent25e4c572eb30e2caae6528ef4f2b784fe5540aff (diff)
downloadsleepy_penguin-a00b3766fa4c498a65f5742e161a382717db3041.tar.gz
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.
-rw-r--r--ext/sleepy_penguin/value2timespec.h4
1 files 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;