summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-11 00:45:13 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-11 00:45:13 (GMT)
commit0966635873d0237c615aced5860802a8a953ff64 (patch)
tree80521a3e0d4d53061b9f5045e9b7a4d7e9d0d295 /dln.c
parent848d6fd55e26016d972ec7779f010479d88590ee (diff)
* dln.c (aix_loaderror): get rid of using uninitialized value in the
case loadquery fails. fixed wrong index variable usage. see [ruby-core:25479]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/dln.c b/dln.c
index b939dc3..4837048 100644
--- a/dln.c
+++ b/dln.c
@@ -1149,10 +1149,10 @@ dln_strerror(void)
static void
aix_loaderror(const char *pathname)
{
- char *message[8], errbuf[1024];
+ char *message[1024], errbuf[1024];
int i,j;
- struct errtab {
+ static const struct errtab {
int errnum;
char *errstr;
} load_errtab[] = {
@@ -1173,15 +1173,16 @@ aix_loaderror(const char *pathname)
#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
- snprintf(errbuf, 1024, "load failed - %s ", pathname);
+ snprintf(errbuf, sizeof(errbuf), "load failed - %s ", pathname);
- if (!loadquery(1, &message[0], sizeof(message)))
+ message[0] = NULL;
+ if (!loadquery(L_GETMESSAGE, &message[0], sizeof(message)))
ERRBUF_APPEND(strerror(errno));
for(i = 0; message[i] && *message[i]; i++) {
int nerr = atoi(message[i]);
for (j=0; j<LOAD_ERRTAB_LEN; j++) {
- if (nerr == load_errtab[i].errnum && load_errtab[i].errstr)
- ERRBUF_APPEND(load_errtab[i].errstr);
+ if (nerr == load_errtab[j].errnum && load_errtab[j].errstr)
+ ERRBUF_APPEND(load_errtab[j].errstr);
}
while (isdigit(*message[i])) message[i]++;
ERRBUF_APPEND(message[i]);