Changeset: 9e8b558da147 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9e8b558da147
Modified Files:
        MonetDB5/src/mal/mal_linker.mx
Branch: Jun2010
Log Message:

defensive programming: prevent potential segfault and plug definit memory leak


diffs (24 lines):

diff -r b7e647657aca -r 9e8b558da147 MonetDB5/src/mal/mal_linker.mx
--- a/MonetDB5/src/mal/mal_linker.mx    Fri May 21 21:38:57 2010 +0200
+++ b/MonetDB5/src/mal/mal_linker.mx    Thu May 27 19:58:38 2010 +0200
@@ -384,6 +384,12 @@
                                if (strcmp(e->d_name + strlen(e->d_name) - 
strlen(ext), ext) == 0) {
                                        strs[lasts] = 
GDKmalloc(strlen(fullname) +
                                                        sizeof(DIR_SEP) + 
strlen(e->d_name) + 1);
+                                       if (strs[lasts] == NULL) {
+                                               while (lasts >= 0)
+                                                       GDKfree(strs[lasts--]);
+                                               GDKfree(fullname);
+                                               return NULL;
+                                       }
                                        sprintf(strs[lasts], "%s%c%s",
                                                        fullname, DIR_SEP, 
GDKstrdup(e->d_name));
                                        lasts++;
@@ -404,6 +410,7 @@
                                        strcpy(fullname + i, strs[c]);
                                        i += strlen(strs[c]);
                                        fullname[i++] = PATH_SEP;
+                                       GDKfree(strs[c]);
                                }
                                fullname[i - 1] = '\0';
                                return fullname;
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to