From 97ade56ea87f9c9a5857bbfba284bae2a14911aa Mon Sep 17 00:00:00 2001 From: Angel Carpintero Date: Tue, 24 Jan 2012 13:59:12 +0100 Subject: [PATCH] Avoid segfault when text_left or text_right uses non supported chars. --- CHANGELOG | 1 + configure | 18 +++++++++--------- draw.c | 11 ++++++++++- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 800b3d5..a4de385 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -76,6 +76,7 @@ Bugfixes * Fixed configure for SDL. * Replace malloc() by calloc(). (Jeroen Massar) * Free file descriptor buffers on exit. + * Avoid segfault when text_left or text_right uses non supported chars. 3.2.12 Summary of Changes diff --git a/configure b/configure index 5b96e29..6398d64 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for motion Git-05b815771a359a3a66c1c06a597cb6b947fefe89. +# Generated by GNU Autoconf 2.67 for motion Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -549,8 +549,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Git-05b815771a359a3a66c1c06a597cb6b947fefe89' -PACKAGE_STRING='motion Git-05b815771a359a3a66c1c06a597cb6b947fefe89' +PACKAGE_VERSION='Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7' +PACKAGE_STRING='motion Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1217,7 +1217,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures motion Git-05b815771a359a3a66c1c06a597cb6b947fefe89 to adapt to many kinds of systems. +\`configure' configures motion Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1278,7 +1278,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion Git-05b815771a359a3a66c1c06a597cb6b947fefe89:";; + short | recursive ) echo "Configuration of motion Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7:";; esac cat <<\_ACEOF @@ -1424,7 +1424,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure Git-05b815771a359a3a66c1c06a597cb6b947fefe89 +motion configure Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2021,7 +2021,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by motion $as_me Git-05b815771a359a3a66c1c06a597cb6b947fefe89, which was +It was created by motion $as_me Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -6531,7 +6531,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by motion $as_me Git-05b815771a359a3a66c1c06a597cb6b947fefe89, which was +This file was extended by motion $as_me Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6593,7 +6593,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -motion config.status Git-05b815771a359a3a66c1c06a597cb6b947fefe89 +motion config.status Git-fcdd33103646f13db62d7c1d97040ea6e78ba7a7 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/draw.c b/draw.c index 1be96ba..9afdb15 100644 --- a/draw.c +++ b/draw.c @@ -1097,10 +1097,19 @@ static int draw_textn(unsigned char *image, unsigned int startx, unsigned int st char_arr_ptr = factor ? big_char_arr_ptr : small_char_arr_ptr; for (pos = 0; pos < len; pos++) { - char_ptr = char_arr_ptr[(int)text[pos]]; + int pos_check = (int)text[pos]; + + char_ptr = char_arr_ptr[pos_check]; for (y = 8 * (factor + 1); y--;) { for (x = 7 * (factor + 1); x--;) { + + if (pos_check < 0) { + image_ptr++; + char_ptr++; + continue; + } + switch(*char_ptr) { case 1: *image_ptr = 0;