File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4617,10 +4617,14 @@ int i;
46174617const char *ap;
46184618const char *fixup_needed = strchr (gbuf, ':');
46194619char *tgbuf = NULL;
4620- size_t tgbuf_size = MAX(rbuf_size, 1 + (size_t)(fixup_needed - gbuf));
4621-
4622- if (fixup_needed) {
4623- tgbuf = (char *)calloc (tgbuf_size, 1);
4620+ /* If fixup_needed == NULL, fixup - gbuf will end up being a VERY large number, so
4621+ * default to a reasonable size. */
4622+ size_t tgbuf_size = rbuf_size;
4623+
4624+ if (fixup_needed != NULL) {
4625+ tgbuf_size = 1 + (size_t) (fixup_needed - gbuf);
4626+ tgbuf = (char *) calloc (tgbuf_size, 1);
4627+ tgbuf[fixup_needed - gbuf] = '\0';
46244628 memcpy (tgbuf, gbuf, (fixup_needed - gbuf));
46254629 gbuf = tgbuf;
46264630 }
@@ -11236,7 +11240,7 @@ CONST char *get_sim_sw (CONST char *cptr)
1123611240int32 lsw, lnum;
1123711241char gbuf[CBUFSIZE];
1123811242
11239- while (*cptr == '-') { /* while switches */
11243+ while (cptr != NULL && *cptr == '-') { /* while switches */
1124011244 cptr = get_glyph (cptr, gbuf, 0); /* get switch glyph */
1124111245 switch (get_switches (gbuf, &lsw, &lnum)) { /* parse */
1124211246 case SW_ERROR:
You can’t perform that action at this time.
0 commit comments