summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/signal.c b/signal.c
index 40caaa660c..5d5cb6b2b6 100644
--- a/signal.c
+++ b/signal.c
@@ -1086,40 +1086,43 @@ trap_handler(VALUE *cmd, int sig)
if (!command) rb_raise(rb_eArgError, "bad handler");
}
if (!NIL_P(command)) {
+ const char *cptr;
+ long len;
SafeStringValue(command); /* taint check */
*cmd = command;
- switch (RSTRING_LEN(command)) {
+ RSTRING_GETMEM(command, cptr, len);
+ switch (len) {
case 0:
goto sig_ign;
break;
case 14:
- if (strncmp(RSTRING_PTR(command), "SYSTEM_DEFAULT", 14) == 0) {
+ if (memcmp(cptr, "SYSTEM_DEFAULT", 14) == 0) {
func = SIG_DFL;
*cmd = 0;
}
break;
case 7:
- if (strncmp(RSTRING_PTR(command), "SIG_IGN", 7) == 0) {
+ if (memcmp(cptr, "SIG_IGN", 7) == 0) {
sig_ign:
func = SIG_IGN;
*cmd = Qtrue;
}
- else if (strncmp(RSTRING_PTR(command), "SIG_DFL", 7) == 0) {
+ else if (memcmp(cptr, "SIG_DFL", 7) == 0) {
sig_dfl:
func = default_handler(sig);
*cmd = 0;
}
- else if (strncmp(RSTRING_PTR(command), "DEFAULT", 7) == 0) {
+ else if (memcmp(cptr, "DEFAULT", 7) == 0) {
goto sig_dfl;
}
break;
case 6:
- if (strncmp(RSTRING_PTR(command), "IGNORE", 6) == 0) {
+ if (memcmp(cptr, "IGNORE", 6) == 0) {
goto sig_ign;
}
break;
case 4:
- if (strncmp(RSTRING_PTR(command), "EXIT", 4) == 0) {
+ if (memcmp(cptr, "EXIT", 4) == 0) {
*cmd = Qundef;
}
break;