]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2006-01-28 15:36:17 by harbaum]
authorharbaum <harbaum@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sat, 28 Jan 2006 15:36:18 +0000 (15:36 +0000)
committerharbaum <harbaum@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sat, 28 Jan 2006 15:36:18 +0000 (15:36 +0000)
Fix: string termination bug in eval()

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@625 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

drv_LCD2USB.c
evaluator.c

index adaecfe86ea82043c591a719413e19bd933c4264..31c66451cadc6363f108e99b45889d8c39e9e920 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_LCD2USB.c,v 1.1 2006/01/26 19:26:27 harbaum Exp $
+/* $Id: drv_LCD2USB.c,v 1.2 2006/01/28 15:36:17 harbaum Exp $
  *
  * driver for USB2LCD display interface
  * see http://www.harbaum.org/till/lcd2usb for schematics
@@ -24,6 +24,9 @@
  *
  * 
  * $Log: drv_LCD2USB.c,v $
+ * Revision 1.2  2006/01/28 15:36:17  harbaum
+ * Fix: string termination bug in eval()
+ *
  * Revision 1.1  2006/01/26 19:26:27  harbaum
  * Added LCD2USB support
  *
@@ -163,7 +166,7 @@ static int drv_L2U_send(int request, int value, int index)
 }
 
 /* to increase performance, a little buffer is being used to */
-/* collect command bytes of the same type before transmissing them */
+/* collect command bytes of the same type before transmitting them */
 #define BUFFER_MAX_CMD 4       /* current protocol supports up to 4 bytes */
 int buffer_current_type = -1;  /* nothing in buffer yet */
 int buffer_current_fill = 0;   /* -"- */
@@ -236,6 +239,8 @@ static void drv_L2U_write(const int row, const int col, const char *data, int le
 {
     int pos;
 
+//    printf("write %d/%d %s(%d)\n", row, col, data, len);
+
     /* 16x4 Displays use a slightly different layout */
     if (DCOLS == 16 && DROWS == 4) {
        pos = (row % 2) * 64 + (row / 2) * 16 + col;
index e4493b315e109311d142bcf031356af143d0c464..d4b4671789a67358105bee6f97410ac3078a16c9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: evaluator.c,v 1.26 2006/01/21 09:40:20 reinelt Exp $
+/* $Id: evaluator.c,v 1.27 2006/01/28 15:36:18 harbaum Exp $
  *
  * expression evaluation
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: evaluator.c,v $
+ * Revision 1.27  2006/01/28 15:36:18  harbaum
+ * Fix: string termination bug in eval()
+ *
  * Revision 1.26  2006/01/21 09:40:20  reinelt
  * Big Memory Leak in Evaluator fixed (thanks to Oliver Gehrke)
  *
@@ -1306,9 +1309,10 @@ int Eval(void *tree, RESULT * result)
     result->length = Tree->Result->length;
     if (result->length >= 0) {
        result->string = malloc(result->length+1);
-       if (Tree->Result->string != NULL)
+       if (Tree->Result->string != NULL) {
            strncpy(result->string, Tree->Result->string, result->length);
-       else
+           result->string[result->length] = 0;
+       } else
            result->string[0] = '\0';
     } else {
        result->string = NULL;