summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--ext/Win32API/Win32API.c2
-rw-r--r--ext/nkf/nkf.c1
-rw-r--r--ext/readline/readline.c4
-rw-r--r--ext/socket/socket.c18
-rw-r--r--ext/tcltklib/tcltklib.c2
6 files changed, 22 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 86ce0411c2c..dafc3e9ac02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri Aug 30 19:35:46 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/Win32API/Win32API.c (Win32API_Call): use StringValuePtr() to
+ confirm ptr is not NULL.
+
+ * ext/socket/socket.c (sock_s_getaddrinfo): ditto.
+
+ * ext/socket/socket.c (sock_s_getnameinfo): ditto.
+
Thu Aug 29 23:34:42 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
* bcc32/MakeFile.sub (sitearch): add.
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index b9f16e25198..179dd496416 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -249,7 +249,7 @@ Win32API_Call(argc, argv, obj)
} else {
StringValue(str);
rb_str_modify(str);
- pParam = RSTRING(str)->ptr;
+ pParam = StringValuePtr(str)
}
#if defined(_MSC_VER) || defined(__LCC__)
#if defined(_M_IX86)
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 50723467cd4..c71a5119aa9 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -104,6 +104,7 @@ rb_nkf_guess(obj, src)
StringValue(src);
p = RSTRING(src)->ptr;
pend = p + RSTRING(src)->len;
+ if (p == pend) return INT2FIX(_UNKNOWN);
#define INCR do {\
p++;\
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 0772d58bcf5..2f460ea3e01 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -191,11 +191,9 @@ readline_s_set_completion_append_character(self, str)
VALUE self, str;
{
#ifdef READLINE_21_OR_LATER
- if (NIL_P(str)) {
+ if (NIL_P(str) || !StringValuePtr(str) || !RSTRING(str)->len) {
rl_completion_append_character = '\0';
} else {
- StringValue(str);
-
rl_completion_append_character = RSTRING(str)->ptr[0];
}
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 1e91c38c674..2e9731dbc41 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -2133,7 +2133,7 @@ sock_s_getaddrinfo(argc, argv)
{
VALUE host, port, family, socktype, protocol, flags, ret;
char hbuf[1024], pbuf[1024];
- char *hptr, *pptr;
+ char *hptr, *pptr, *ap;
struct addrinfo hints, *res;
int error;
@@ -2167,13 +2167,12 @@ sock_s_getaddrinfo(argc, argv)
else if (FIXNUM_P(family)) {
hints.ai_family = FIX2INT(family);
}
- else {
- StringValue(family);
- if (strcmp(RSTRING(family)->ptr, "AF_INET") == 0) {
+ else if ((ap = StringValuePtr(family)) != 0) {
+ if (strcmp(ap, "AF_INET") == 0) {
hints.ai_family = PF_INET;
}
#ifdef INET6
- else if (strcmp(RSTRING(family)->ptr, "AF_INET6") == 0) {
+ else if (strcmp(ap, "AF_INET6") == 0) {
hints.ai_family = PF_INET6;
}
#endif
@@ -2211,7 +2210,7 @@ sock_s_getnameinfo(argc, argv)
int error;
struct sockaddr_storage ss;
struct sockaddr *sap;
- char *ep;
+ char *ep, *ap;
sa = flags = Qnil;
rb_scan_args(argc, argv, "11", &sa, &flags);
@@ -2287,13 +2286,12 @@ sock_s_getnameinfo(argc, argv)
else if (FIXNUM_P(af)) {
hints.ai_family = FIX2INT(af);
}
- else {
- StringValue(af);
- if (strcmp(RSTRING(af)->ptr, "AF_INET") == 0) {
+ else if ((ap = StringValuePtr(af)) != 0) {
+ if (strcmp(ap, "AF_INET") == 0) {
hints.ai_family = PF_INET;
}
#ifdef INET6
- else if (strcmp(RSTRING(af)->ptr, "AF_INET6") == 0) {
+ else if (ap, "AF_INET6") == 0) {
hints.ai_family = PF_INET6;
}
#endif
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 1b59006009f..b75af3fc775 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -565,6 +565,7 @@ ip_toUTF8(self, str, encodename)
StringValue(encodename);
StringValue(str);
encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
+ if (!RSTRING(str)->len) return str;
buf = ALLOCA_N(char,strlen(RSTRING(str)->ptr)+1);
strcpy(buf, RSTRING(str)->ptr);
@@ -598,6 +599,7 @@ ip_fromUTF8(self, str, encodename)
StringValue(encodename);
StringValue(str);
encoding = Tcl_GetEncoding(interp,RSTRING(encodename)->ptr);
+ if (!RSTRING(str)->len) return str;
buf = ALLOCA_N(char,strlen(RSTRING(str)->ptr)+1);
strcpy(buf,RSTRING(str)->ptr);