Author: mladen.turk(a)jboss.com
Date: 2007-09-08 12:42:14 -0400 (Sat, 08 Sep 2007)
New Revision: 988
Modified:
trunk/sight/native/share/jnu.c
Log:
Return errno on malloc fails
Modified: trunk/sight/native/share/jnu.c
===================================================================
--- trunk/sight/native/share/jnu.c 2007-09-07 08:04:14 UTC (rev 987)
+++ trunk/sight/native/share/jnu.c 2007-09-08 16:42:14 UTC (rev 988)
@@ -785,7 +785,11 @@
free(a->arr.ca);
a->len = len;
a->arr.ca = na;
- a->arr.ca[a->siz++] = strdup(str);
+ a->arr.ca[a->siz] = strdup(str);
+ if (!a->arr.ca[a->siz])
+ return errno;
+ else
+ a->siz++;
}
return 0;
}
@@ -834,12 +838,16 @@
FILE *file;
/* Filename and comment are mandatory */
- if (!fname || !cmnt)
+ if (!fname || !cmnt) {
+ errno = EINVAL;
return NULL;
+ }
if (!(file = fopen(fname, "r")))
return NULL;
if (!(array = sight_arr_new(16))) {
+ int saved_errno = errno;
fclose(file);
+ errno = saved_errno;
return NULL;
}
while (fgets(&buf[0], 8192, file)) {
Show replies by date