summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sgr.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/sgr.c b/src/sgr.c
index baec803..9e77f18 100644
--- a/src/sgr.c
+++ b/src/sgr.c
@@ -61,7 +61,15 @@ sgr(char *param, png_colorp fg, png_colorp bg)
end = 1;
}
*param = '\0';
- i = atoi(p);
+ if (*p) {
+ i = atoi(p);
+ } else {
+ i = 0;
+ }
+ if (i == 0) { /* Reset */
+ memcpy(fg, &_4bit[7], sizeof(*fg));
+ memcpy(bg, &_4bit[0], sizeof(*bg));
+ }
if (i >= 30 && i <= 37) { /* Set foreground color */
memcpy(fg, &_4bit[i - 30], sizeof(*fg));
}