From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: normalperson@yhbt.net Received: from zedshaw2.xen.prgmr.com (zedshaw2.xen.prgmr.com [71.19.156.177]) by dcvr.yhbt.net (Postfix) with ESMTP id 893252028E for ; Thu, 21 Nov 2013 18:48:49 +0000 (UTC) Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id 02B0274BD9 for ; Thu, 21 Nov 2013 18:51:15 +0000 (UTC) MIME-Version: 1.0 Date: Thu, 21 Nov 2013 18:48:42 +0000 From: Eric Wong In-Reply-To: <20131121184842.GB9059@dcvr.yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Message-Id: <20131121184842.GB9059@dcvr.yhbt.net> Precedence: list References: <20131121184842.GB9059@dcvr.yhbt.net> Sender: sleepy.penguin@librelist.org Subject: [sleepy.penguin] [PATCH] value2timespec: use StringValueCStr for correctness To: sleepy.penguin@librelist.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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; -- 1.8.5.rc2.1.g2f4e96a