DtTerm: Coverity (memory corruption, moderate)
authorJon Trulson <jon@radscan.com>
Fri, 26 Dec 2014 22:59:52 +0000 (15:59 -0700)
committerJon Trulson <jon@radscan.com>
Fri, 26 Dec 2014 22:59:52 +0000 (15:59 -0700)
cde/lib/DtTerm/TermPrim/TermPrimDebug.c

index c79d8a108e618f5e1eb6db7f86b840384c35f461..89a9e22e0f2db7e1081183c272a0c2ac9f91d6ab 100644 (file)
@@ -444,15 +444,15 @@ enumToName
 {
     int                  i1;
     char                 buffer[BUFSIZ];
-    static char                 *retBuffer = (char *) 0;
+    static char                 *retBuffer = NULL;
 
     for (i1 = 0; list[i1].string; i1++) {
        if (list[i1].value == value) {
            return(list[i1].string);
        }
     }
-    (void) sprintf(buffer, "Unknown Value %d", value);
-    retBuffer = realloc(retBuffer, strlen(buffer));
+    snprintf(buffer, BUFSIZ, "Unknown Value %d", value);
+    retBuffer = realloc(retBuffer, strlen(buffer) + 1);
     (void) strcpy(retBuffer, buffer);
     return(retBuffer);
 }
@@ -467,14 +467,14 @@ _DtTermPrimDebugDumpEvent
 {
     _DtTermProcessLock();
     (void) fprintf(f, ">>  widget: name=\"%s\"  widget=0x%lx  window=0x%lx\n",
-           XtName(w), w, XtWindow(w));
+                   XtName(w), (long)w, XtWindow(w));
     (void) fprintf(f, ">> event {\n");
     (void) fprintf(f, ">>     type=%s;\n",
            enumToName(eventTypes, ev->xany.type));
     (void) fprintf(f, ">>     serial=%lu\n", ev->xany.serial);
     (void) fprintf(f, ">>     send_event=%s\n",
            enumToName(boolTypes, ev->xany.send_event));
-    (void) fprintf(f, ">>     display=0x%lx\n", ev->xany.display);
+    (void) fprintf(f, ">>     display=0x%lx\n", (long)ev->xany.display);
     (void) fprintf(f, ">>     window=0x%lx\n", ev->xany.window);
     switch (ev->type) {
     case EnterNotify: