Avoid test failures on AIX and OSF/1.
[gnulib.git] / lib / unilbrk / ulc-possible-linebreaks.c
index 74cd42a..2032154 100644 (file)
@@ -1,5 +1,5 @@
 /* Line breaking of strings.
-   Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2006-2009 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify it
@@ -62,9 +62,9 @@ ulc_possible_linebreaks (const char *s, size_t n, const char *encoding,
                                         s, n, offsets, &t, &m)
                  == 0)
                {
-                 char *q = (char *) malloc (m);
+                 char *q = (char *) (m > 0 ? malloc (m) : NULL);
 
-                 if (q != NULL)
+                 if (m == 0 || q != NULL)
                    {
                      size_t i;