[PATCH] allocating error handling in modstub.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I added checking code after strdup and realloc
in modstub.c

thank you.
--- loader2/modstubs.c  14 Aug 2007 19:23:41 -0000      1.15
+++ loader2/modstubs.c  31 Aug 2007 03:19:05 -0000
@@ -95,6 +95,12 @@
         return usage();
     }

+    if (!options) {
+        logMessage(ERROR, "cannot allocate memory for options: %s",
+                   strerror(errno));
+        return 1;
+    }
+
     while (argc > 2) {
         if (!strcmp(argv[1], "-p")) {
             ballPath = malloc(strlen(argv[2]) + 30);
@@ -143,6 +149,11 @@
     for (i = 2; i < argc; i++) {
         options = realloc(options,
                           strlen(options) + 1 + strlen(argv[i]) + 1);
+        if (!options) {
+            logMessage(ERROR, "cannot allocate memory for options: %s",
+                       strerror(errno));
+            return 1;
+        }
         strcat(options, argv[i]);
         strcat(options, " ");
      }

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux