first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[kai/samba.git] / source3 / printing / print_svid.c
index 5c5eebeb5028c193c59661af4fe5cddb2a6aec15..85eaf8f95dd5a38fe5cd8d53e5c2c19e7e5ee02e 100644 (file)
@@ -60,7 +60,17 @@ static void populate_printers(void)
                        if (((tmp = strchr(buf, ' ')) == NULL) ||
                            ((tmp = strchr(++tmp, ' ')) == NULL))
                                continue;
-                       name = ++tmp;
+
+                       /*
+                        * In case we're only at the "for ".
+                        */
+
+            if(!strncmp("for ",++tmp,4))
+            {
+                               tmp=strchr(tmp, ' ');
+                               tmp++;
+                       }
+                       name = tmp;
 
                        /* truncate the ": ..." */
                        if ((tmp = strchr(name, ':')) != NULL)
@@ -69,9 +79,12 @@ static void populate_printers(void)
                        /* add it to the cache */
                        if ((ptmp = malloc(sizeof (*ptmp))) != NULL) {
                                ZERO_STRUCTP(ptmp);
-                               ptmp->name = strdup(name);
+                               if((ptmp->name = strdup(name)) == NULL)
+                                       DEBUG(0,("populate_printers: malloc fail in strdup !\n"));
                                ptmp->next = printers;
                                printers = ptmp;
+                       } else {
+                               DEBUG(0,("populate_printers: malloc fail for ptmp\n"));
                        }
                }
                pclose(fp);